{"action":"created","comment":{"url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/comments/48349307","id":48349307,"diff_hunk":"@@ -0,0 +1,50 @@\n+'use strict';\n+\n+var aws = require('aws-sdk');\n+var through2 = require('through2');\n+\n+class awsS3Storage {\n+  /**\n+   * @param {object} options - A hash of options.\n+   * @param {string} options.fileStorage - The path in which to store the files.\n+   */\n+  constructor(options) {\n+    this.fileStorage = options;\n+    aws.config.accessKeyId = options.awsAccessKeyId;\n+    aws.config.secretAccessKey = options.awsSecretAccessKey;\n+    this.s3obj = new aws.S3({params: {Bucket: options.bucket}});\n+    var throughStream = through2();\n+  }\n+\n+  /**\n+   * Create a writeable stream to which we can write file data.\n+   *\n+   * @param {string} assetName - The name of the asset that needs to be written.\n+   * @return {object} - The writeable stream to store the data.\n+   */\n+  createWriteStream(assetName) {\n+    var writeStream = through2();\n+    var self = this;\n+    self.s3obj.upload({Key: assetName, Body: writeStream})\n+      .send(function (err, data) {\n+      });\n+    return writeStream;\n+  }\n+\n+  /**\n+   * Create a readable stream to which we can write file data.\n+   *\n+   * @param {string} assetName - The name of the asset that needs to be written.\n+   * @return {object} - The writeable stream to store the data.\n+   */\n+  createReadStream(assetName) {\n+    var writeStream = through2();\n+    var self = this;\n+    self.s3obj.upload({Key: assetName, Body: writeStream})","path":"lib/plugins/fileStorage/awsS3Storage.js","position":43,"original_position":43,"commit_id":"fe0ce322c8a06dfb1e3e4b9f962834e640264c49","original_commit_id":"fe0ce322c8a06dfb1e3e4b9f962834e640264c49","user":{"login":"tizzo","id":245728,"avatar_url":"https://avatars.githubusercontent.com/u/245728?v=3","gravatar_id":"","url":"https://api.github.com/users/tizzo","html_url":"https://github.com/tizzo","followers_url":"https://api.github.com/users/tizzo/followers","following_url":"https://api.github.com/users/tizzo/following{/other_user}","gists_url":"https://api.github.com/users/tizzo/gists{/gist_id}","starred_url":"https://api.github.com/users/tizzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tizzo/subscriptions","organizations_url":"https://api.github.com/users/tizzo/orgs","repos_url":"https://api.github.com/users/tizzo/repos","events_url":"https://api.github.com/users/tizzo/events{/privacy}","received_events_url":"https://api.github.com/users/tizzo/received_events","type":"User","site_admin":false},"body":"This appears to just be trying to upload the assets again - we must not have tested reading files back out of S3 as it definitely isn't working right now.","created_at":"2015-12-23T14:39:30Z","updated_at":"2015-12-23T14:39:30Z","html_url":"https://github.com/ProboCI/probo-asset-receiver/pull/1#discussion_r48349307","pull_request_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/comments/48349307"},"html":{"href":"https://github.com/ProboCI/probo-asset-receiver/pull/1#discussion_r48349307"},"pull_request":{"href":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/1","id":51747911,"html_url":"https://github.com/ProboCI/probo-asset-receiver/pull/1","diff_url":"https://github.com/ProboCI/probo-asset-receiver/pull/1.diff","patch_url":"https://github.com/ProboCI/probo-asset-receiver/pull/1.patch","issue_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues/1","number":1,"state":"open","locked":false,"title":"Create S3 file storage plugin","user":{"login":"tizzo","id":245728,"avatar_url":"https://avatars.githubusercontent.com/u/245728?v=3","gravatar_id":"","url":"https://api.github.com/users/tizzo","html_url":"https://github.com/tizzo","followers_url":"https://api.github.com/users/tizzo/followers","following_url":"https://api.github.com/users/tizzo/following{/other_user}","gists_url":"https://api.github.com/users/tizzo/gists{/gist_id}","starred_url":"https://api.github.com/users/tizzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tizzo/subscriptions","organizations_url":"https://api.github.com/users/tizzo/orgs","repos_url":"https://api.github.com/users/tizzo/repos","events_url":"https://api.github.com/users/tizzo/events{/privacy}","received_events_url":"https://api.github.com/users/tizzo/received_events","type":"User","site_admin":false},"body":"For the long term we do not want to be storing our build assets on the local filesystem. It is more expensive, less scalable, and probably less reliable than pushing this off onto S3.  We should create a plugin for sending that to S3. I think the [official AWS module](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-examples.html) now has support and examples for streaming uploads and downloads.\r\n\r\n","created_at":"2015-11-25T03:14:39Z","updated_at":"2015-12-23T14:39:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"90b058a74b51d8a791dccaf93edb25d35dddcc1a","assignee":{"login":"tizzo","id":245728,"avatar_url":"https://avatars.githubusercontent.com/u/245728?v=3","gravatar_id":"","url":"https://api.github.com/users/tizzo","html_url":"https://github.com/tizzo","followers_url":"https://api.github.com/users/tizzo/followers","following_url":"https://api.github.com/users/tizzo/following{/other_user}","gists_url":"https://api.github.com/users/tizzo/gists{/gist_id}","starred_url":"https://api.github.com/users/tizzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tizzo/subscriptions","organizations_url":"https://api.github.com/users/tizzo/orgs","repos_url":"https://api.github.com/users/tizzo/repos","events_url":"https://api.github.com/users/tizzo/events{/privacy}","received_events_url":"https://api.github.com/users/tizzo/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/1/commits","review_comments_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/1/comments","review_comment_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues/1/comments","statuses_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/statuses/fe0ce322c8a06dfb1e3e4b9f962834e640264c49","head":{"label":"ProboCI:file-storage-s3-plugin","ref":"file-storage-s3-plugin","sha":"fe0ce322c8a06dfb1e3e4b9f962834e640264c49","user":{"login":"ProboCI","id":12071240,"avatar_url":"https://avatars.githubusercontent.com/u/12071240?v=3","gravatar_id":"","url":"https://api.github.com/users/ProboCI","html_url":"https://github.com/ProboCI","followers_url":"https://api.github.com/users/ProboCI/followers","following_url":"https://api.github.com/users/ProboCI/following{/other_user}","gists_url":"https://api.github.com/users/ProboCI/gists{/gist_id}","starred_url":"https://api.github.com/users/ProboCI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProboCI/subscriptions","organizations_url":"https://api.github.com/users/ProboCI/orgs","repos_url":"https://api.github.com/users/ProboCI/repos","events_url":"https://api.github.com/users/ProboCI/events{/privacy}","received_events_url":"https://api.github.com/users/ProboCI/received_events","type":"Organization","site_admin":false},"repo":{"id":41899284,"name":"probo-asset-receiver","full_name":"ProboCI/probo-asset-receiver","owner":{"login":"ProboCI","id":12071240,"avatar_url":"https://avatars.githubusercontent.com/u/12071240?v=3","gravatar_id":"","url":"https://api.github.com/users/ProboCI","html_url":"https://github.com/ProboCI","followers_url":"https://api.github.com/users/ProboCI/followers","following_url":"https://api.github.com/users/ProboCI/following{/other_user}","gists_url":"https://api.github.com/users/ProboCI/gists{/gist_id}","starred_url":"https://api.github.com/users/ProboCI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProboCI/subscriptions","organizations_url":"https://api.github.com/users/ProboCI/orgs","repos_url":"https://api.github.com/users/ProboCI/repos","events_url":"https://api.github.com/users/ProboCI/events{/privacy}","received_events_url":"https://api.github.com/users/ProboCI/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ProboCI/probo-asset-receiver","description":"A simple service for storing assets in a bucket and allowing them to be retrieved later.","fork":false,"url":"https://api.github.com/repos/ProboCI/probo-asset-receiver","forks_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/forks","keys_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/teams","hooks_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/hooks","issue_events_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues/events{/number}","events_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/events","assignees_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/assignees{/user}","branches_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/branches{/branch}","tags_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/tags","blobs_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/refs{/sha}","trees_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/statuses/{sha}","languages_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/languages","stargazers_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/stargazers","contributors_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/contributors","subscribers_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/subscribers","subscription_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/subscription","commits_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/commits{/sha}","git_commits_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/commits{/sha}","comments_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/comments{/number}","issue_comment_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues/comments{/number}","contents_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/contents/{+path}","compare_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/merges","archive_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/downloads","issues_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues{/number}","pulls_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls{/number}","milestones_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/milestones{/number}","notifications_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/labels{/name}","releases_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/releases{/id}","created_at":"2015-09-04T05:25:29Z","updated_at":"2015-09-04T05:25:40Z","pushed_at":"2015-12-21T22:39:09Z","git_url":"git://github.com/ProboCI/probo-asset-receiver.git","ssh_url":"git@github.com:ProboCI/probo-asset-receiver.git","clone_url":"https://github.com/ProboCI/probo-asset-receiver.git","svn_url":"https://github.com/ProboCI/probo-asset-receiver","homepage":null,"size":33,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ProboCI:master","ref":"master","sha":"0f69529bd7a37ecad1d214ca14dcc4b5d4febb38","user":{"login":"ProboCI","id":12071240,"avatar_url":"https://avatars.githubusercontent.com/u/12071240?v=3","gravatar_id":"","url":"https://api.github.com/users/ProboCI","html_url":"https://github.com/ProboCI","followers_url":"https://api.github.com/users/ProboCI/followers","following_url":"https://api.github.com/users/ProboCI/following{/other_user}","gists_url":"https://api.github.com/users/ProboCI/gists{/gist_id}","starred_url":"https://api.github.com/users/ProboCI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProboCI/subscriptions","organizations_url":"https://api.github.com/users/ProboCI/orgs","repos_url":"https://api.github.com/users/ProboCI/repos","events_url":"https://api.github.com/users/ProboCI/events{/privacy}","received_events_url":"https://api.github.com/users/ProboCI/received_events","type":"Organization","site_admin":false},"repo":{"id":41899284,"name":"probo-asset-receiver","full_name":"ProboCI/probo-asset-receiver","owner":{"login":"ProboCI","id":12071240,"avatar_url":"https://avatars.githubusercontent.com/u/12071240?v=3","gravatar_id":"","url":"https://api.github.com/users/ProboCI","html_url":"https://github.com/ProboCI","followers_url":"https://api.github.com/users/ProboCI/followers","following_url":"https://api.github.com/users/ProboCI/following{/other_user}","gists_url":"https://api.github.com/users/ProboCI/gists{/gist_id}","starred_url":"https://api.github.com/users/ProboCI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProboCI/subscriptions","organizations_url":"https://api.github.com/users/ProboCI/orgs","repos_url":"https://api.github.com/users/ProboCI/repos","events_url":"https://api.github.com/users/ProboCI/events{/privacy}","received_events_url":"https://api.github.com/users/ProboCI/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ProboCI/probo-asset-receiver","description":"A simple service for storing assets in a bucket and allowing them to be retrieved later.","fork":false,"url":"https://api.github.com/repos/ProboCI/probo-asset-receiver","forks_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/forks","keys_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/teams","hooks_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/hooks","issue_events_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues/events{/number}","events_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/events","assignees_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/assignees{/user}","branches_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/branches{/branch}","tags_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/tags","blobs_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/refs{/sha}","trees_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/statuses/{sha}","languages_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/languages","stargazers_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/stargazers","contributors_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/contributors","subscribers_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/subscribers","subscription_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/subscription","commits_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/commits{/sha}","git_commits_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/git/commits{/sha}","comments_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/comments{/number}","issue_comment_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues/comments{/number}","contents_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/contents/{+path}","compare_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/merges","archive_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/downloads","issues_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues{/number}","pulls_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls{/number}","milestones_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/milestones{/number}","notifications_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/labels{/name}","releases_url":"https://api.github.com/repos/ProboCI/probo-asset-receiver/releases{/id}","created_at":"2015-09-04T05:25:29Z","updated_at":"2015-09-04T05:25:40Z","pushed_at":"2015-12-21T22:39:09Z","git_url":"git://github.com/ProboCI/probo-asset-receiver.git","ssh_url":"git@github.com:ProboCI/probo-asset-receiver.git","clone_url":"https://github.com/ProboCI/probo-asset-receiver.git","svn_url":"https://github.com/ProboCI/probo-asset-receiver","homepage":null,"size":33,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/1"},"html":{"href":"https://github.com/ProboCI/probo-asset-receiver/pull/1"},"issue":{"href":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues/1"},"comments":{"href":"https://api.github.com/repos/ProboCI/probo-asset-receiver/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ProboCI/probo-asset-receiver/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/ProboCI/probo-asset-receiver/statuses/fe0ce322c8a06dfb1e3e4b9f962834e640264c49"}}}}