{"action":"created","comment":{"url":"https://api.github.com/repos/strapi/strapi/pulls/comments/169580742","pull_request_review_id":98126969,"id":169580742,"diff_hunk":"@@ -6,6 +6,116 @@\n  * @description: A set of functions similar to controller's actions to avoid code duplication.\n  */\n \n+const _ = require('lodash');\n+const path = require('path');\n+const fs = require('fs');\n+const toArray = require('stream-to-array');\n+const uuid = require('uuid/v4');\n+\n module.exports = {\n+  buffurize: async values => {\n+    if (_.size(values.files) === 0) {\n+      throw 'Missing files.';\n+    }\n+\n+    const files = _.isArray(values.files) ? values.files : [values.files];\n+\n+    return Promise.all(\n+      files.map(async stream => {\n+        const parts = await toArray(fs.createReadStream(stream.path));\n+        const buffers = parts.map(\n+          part => _.isBuffer(part) ? part : Buffer.from(part)\n+        );\n+\n+        return {\n+          name: stream.name,\n+          hash: uuid().replace(/-/g, ''),\n+          ext: _.last(stream.name.split('.')),\n+          buffer: Buffer.concat(buffers),\n+          mime: stream.type,\n+          size: `${(stream.size / 1000).toFixed(2)} KB`","path":"packages/strapi-plugin-upload/services/Upload.js","position":31,"original_position":31,"commit_id":"37d00cae42dacdcbe55d96300c91c6e07873d345","original_commit_id":"37d00cae42dacdcbe55d96300c91c6e07873d345","user":{"login":"Aurelsicoko","id":4144726,"avatar_url":"https://avatars0.githubusercontent.com/u/4144726?v=4","gravatar_id":"","url":"https://api.github.com/users/Aurelsicoko","html_url":"https://github.com/Aurelsicoko","followers_url":"https://api.github.com/users/Aurelsicoko/followers","following_url":"https://api.github.com/users/Aurelsicoko/following{/other_user}","gists_url":"https://api.github.com/users/Aurelsicoko/gists{/gist_id}","starred_url":"https://api.github.com/users/Aurelsicoko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aurelsicoko/subscriptions","organizations_url":"https://api.github.com/users/Aurelsicoko/orgs","repos_url":"https://api.github.com/users/Aurelsicoko/repos","events_url":"https://api.github.com/users/Aurelsicoko/events{/privacy}","received_events_url":"https://api.github.com/users/Aurelsicoko/received_events","type":"User","site_admin":false},"body":"Remove `KB` to make the sort easier","created_at":"2018-02-21T09:44:59Z","updated_at":"2018-02-21T09:44:59Z","html_url":"https://github.com/strapi/strapi/pull/671#discussion_r169580742","pull_request_url":"https://api.github.com/repos/strapi/strapi/pulls/671","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/strapi/strapi/pulls/comments/169580742"},"html":{"href":"https://github.com/strapi/strapi/pull/671#discussion_r169580742"},"pull_request":{"href":"https://api.github.com/repos/strapi/strapi/pulls/671"}}},"pull_request":{"url":"https://api.github.com/repos/strapi/strapi/pulls/671","id":170033140,"html_url":"https://github.com/strapi/strapi/pull/671","diff_url":"https://github.com/strapi/strapi/pull/671.diff","patch_url":"https://github.com/strapi/strapi/pull/671.patch","issue_url":"https://api.github.com/repos/strapi/strapi/issues/671","number":671,"state":"open","locked":false,"title":"File upload backend","user":{"login":"lauriejim","id":5716596,"avatar_url":"https://avatars3.githubusercontent.com/u/5716596?v=4","gravatar_id":"","url":"https://api.github.com/users/lauriejim","html_url":"https://github.com/lauriejim","followers_url":"https://api.github.com/users/lauriejim/followers","following_url":"https://api.github.com/users/lauriejim/following{/other_user}","gists_url":"https://api.github.com/users/lauriejim/gists{/gist_id}","starred_url":"https://api.github.com/users/lauriejim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lauriejim/subscriptions","organizations_url":"https://api.github.com/users/lauriejim/orgs","repos_url":"https://api.github.com/users/lauriejim/repos","events_url":"https://api.github.com/users/lauriejim/events{/privacy}","received_events_url":"https://api.github.com/users/lauriejim/received_events","type":"User","site_admin":false},"body":"⚠️ Must be read after this PR https://github.com/strapi/strapi/pull/656 merge\r\n\r\n- Add route to upload new files on local server in `public/upload` folder.\r\n- Delete local file\r\n- Count files\r\n","created_at":"2018-02-19T18:59:45Z","updated_at":"2018-02-21T09:44:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"84108293de92b27a6971a87377a5d977d168179c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/strapi/strapi/pulls/671/commits","review_comments_url":"https://api.github.com/repos/strapi/strapi/pulls/671/comments","review_comment_url":"https://api.github.com/repos/strapi/strapi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/strapi/strapi/issues/671/comments","statuses_url":"https://api.github.com/repos/strapi/strapi/statuses/37d00cae42dacdcbe55d96300c91c6e07873d345","head":{"label":"strapi:file-upload-backend","ref":"file-upload-backend","sha":"37d00cae42dacdcbe55d96300c91c6e07873d345","user":{"login":"strapi","id":19872173,"avatar_url":"https://avatars2.githubusercontent.com/u/19872173?v=4","gravatar_id":"","url":"https://api.github.com/users/strapi","html_url":"https://github.com/strapi","followers_url":"https://api.github.com/users/strapi/followers","following_url":"https://api.github.com/users/strapi/following{/other_user}","gists_url":"https://api.github.com/users/strapi/gists{/gist_id}","starred_url":"https://api.github.com/users/strapi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strapi/subscriptions","organizations_url":"https://api.github.com/users/strapi/orgs","repos_url":"https://api.github.com/users/strapi/repos","events_url":"https://api.github.com/users/strapi/events{/privacy}","received_events_url":"https://api.github.com/users/strapi/received_events","type":"Organization","site_admin":false},"repo":{"id":43441403,"name":"strapi","full_name":"strapi/strapi","owner":{"login":"strapi","id":19872173,"avatar_url":"https://avatars2.githubusercontent.com/u/19872173?v=4","gravatar_id":"","url":"https://api.github.com/users/strapi","html_url":"https://github.com/strapi","followers_url":"https://api.github.com/users/strapi/followers","following_url":"https://api.github.com/users/strapi/following{/other_user}","gists_url":"https://api.github.com/users/strapi/gists{/gist_id}","starred_url":"https://api.github.com/users/strapi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strapi/subscriptions","organizations_url":"https://api.github.com/users/strapi/orgs","repos_url":"https://api.github.com/users/strapi/repos","events_url":"https://api.github.com/users/strapi/events{/privacy}","received_events_url":"https://api.github.com/users/strapi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strapi/strapi","description":":rocket: Node.js Content Management Framework (headless-CMS) to build powerful API with no effort.","fork":false,"url":"https://api.github.com/repos/strapi/strapi","forks_url":"https://api.github.com/repos/strapi/strapi/forks","keys_url":"https://api.github.com/repos/strapi/strapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strapi/strapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strapi/strapi/teams","hooks_url":"https://api.github.com/repos/strapi/strapi/hooks","issue_events_url":"https://api.github.com/repos/strapi/strapi/issues/events{/number}","events_url":"https://api.github.com/repos/strapi/strapi/events","assignees_url":"https://api.github.com/repos/strapi/strapi/assignees{/user}","branches_url":"https://api.github.com/repos/strapi/strapi/branches{/branch}","tags_url":"https://api.github.com/repos/strapi/strapi/tags","blobs_url":"https://api.github.com/repos/strapi/strapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strapi/strapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strapi/strapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/strapi/strapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strapi/strapi/statuses/{sha}","languages_url":"https://api.github.com/repos/strapi/strapi/languages","stargazers_url":"https://api.github.com/repos/strapi/strapi/stargazers","contributors_url":"https://api.github.com/repos/strapi/strapi/contributors","subscribers_url":"https://api.github.com/repos/strapi/strapi/subscribers","subscription_url":"https://api.github.com/repos/strapi/strapi/subscription","commits_url":"https://api.github.com/repos/strapi/strapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/strapi/strapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/strapi/strapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/strapi/strapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/strapi/strapi/contents/{+path}","compare_url":"https://api.github.com/repos/strapi/strapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strapi/strapi/merges","archive_url":"https://api.github.com/repos/strapi/strapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strapi/strapi/downloads","issues_url":"https://api.github.com/repos/strapi/strapi/issues{/number}","pulls_url":"https://api.github.com/repos/strapi/strapi/pulls{/number}","milestones_url":"https://api.github.com/repos/strapi/strapi/milestones{/number}","notifications_url":"https://api.github.com/repos/strapi/strapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strapi/strapi/labels{/name}","releases_url":"https://api.github.com/repos/strapi/strapi/releases{/id}","deployments_url":"https://api.github.com/repos/strapi/strapi/deployments","created_at":"2015-09-30T15:34:48Z","updated_at":"2018-02-21T09:20:30Z","pushed_at":"2018-02-20T19:05:56Z","git_url":"git://github.com/strapi/strapi.git","ssh_url":"git@github.com:strapi/strapi.git","clone_url":"https://github.com/strapi/strapi.git","svn_url":"https://github.com/strapi/strapi","homepage":"https://strapi.io","size":31931,"stargazers_count":3351,"watchers_count":3351,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":252,"mirror_url":null,"archived":false,"open_issues_count":48,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":252,"open_issues":48,"watchers":3351,"default_branch":"master"}},"base":{"label":"strapi:master","ref":"master","sha":"819c16bcdb07b358e971944b2b8228124d495d25","user":{"login":"strapi","id":19872173,"avatar_url":"https://avatars2.githubusercontent.com/u/19872173?v=4","gravatar_id":"","url":"https://api.github.com/users/strapi","html_url":"https://github.com/strapi","followers_url":"https://api.github.com/users/strapi/followers","following_url":"https://api.github.com/users/strapi/following{/other_user}","gists_url":"https://api.github.com/users/strapi/gists{/gist_id}","starred_url":"https://api.github.com/users/strapi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strapi/subscriptions","organizations_url":"https://api.github.com/users/strapi/orgs","repos_url":"https://api.github.com/users/strapi/repos","events_url":"https://api.github.com/users/strapi/events{/privacy}","received_events_url":"https://api.github.com/users/strapi/received_events","type":"Organization","site_admin":false},"repo":{"id":43441403,"name":"strapi","full_name":"strapi/strapi","owner":{"login":"strapi","id":19872173,"avatar_url":"https://avatars2.githubusercontent.com/u/19872173?v=4","gravatar_id":"","url":"https://api.github.com/users/strapi","html_url":"https://github.com/strapi","followers_url":"https://api.github.com/users/strapi/followers","following_url":"https://api.github.com/users/strapi/following{/other_user}","gists_url":"https://api.github.com/users/strapi/gists{/gist_id}","starred_url":"https://api.github.com/users/strapi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strapi/subscriptions","organizations_url":"https://api.github.com/users/strapi/orgs","repos_url":"https://api.github.com/users/strapi/repos","events_url":"https://api.github.com/users/strapi/events{/privacy}","received_events_url":"https://api.github.com/users/strapi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strapi/strapi","description":":rocket: Node.js Content Management Framework (headless-CMS) to build powerful API with no effort.","fork":false,"url":"https://api.github.com/repos/strapi/strapi","forks_url":"https://api.github.com/repos/strapi/strapi/forks","keys_url":"https://api.github.com/repos/strapi/strapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strapi/strapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strapi/strapi/teams","hooks_url":"https://api.github.com/repos/strapi/strapi/hooks","issue_events_url":"https://api.github.com/repos/strapi/strapi/issues/events{/number}","events_url":"https://api.github.com/repos/strapi/strapi/events","assignees_url":"https://api.github.com/repos/strapi/strapi/assignees{/user}","branches_url":"https://api.github.com/repos/strapi/strapi/branches{/branch}","tags_url":"https://api.github.com/repos/strapi/strapi/tags","blobs_url":"https://api.github.com/repos/strapi/strapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strapi/strapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strapi/strapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/strapi/strapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strapi/strapi/statuses/{sha}","languages_url":"https://api.github.com/repos/strapi/strapi/languages","stargazers_url":"https://api.github.com/repos/strapi/strapi/stargazers","contributors_url":"https://api.github.com/repos/strapi/strapi/contributors","subscribers_url":"https://api.github.com/repos/strapi/strapi/subscribers","subscription_url":"https://api.github.com/repos/strapi/strapi/subscription","commits_url":"https://api.github.com/repos/strapi/strapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/strapi/strapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/strapi/strapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/strapi/strapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/strapi/strapi/contents/{+path}","compare_url":"https://api.github.com/repos/strapi/strapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strapi/strapi/merges","archive_url":"https://api.github.com/repos/strapi/strapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strapi/strapi/downloads","issues_url":"https://api.github.com/repos/strapi/strapi/issues{/number}","pulls_url":"https://api.github.com/repos/strapi/strapi/pulls{/number}","milestones_url":"https://api.github.com/repos/strapi/strapi/milestones{/number}","notifications_url":"https://api.github.com/repos/strapi/strapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strapi/strapi/labels{/name}","releases_url":"https://api.github.com/repos/strapi/strapi/releases{/id}","deployments_url":"https://api.github.com/repos/strapi/strapi/deployments","created_at":"2015-09-30T15:34:48Z","updated_at":"2018-02-21T09:20:30Z","pushed_at":"2018-02-20T19:05:56Z","git_url":"git://github.com/strapi/strapi.git","ssh_url":"git@github.com:strapi/strapi.git","clone_url":"https://github.com/strapi/strapi.git","svn_url":"https://github.com/strapi/strapi","homepage":"https://strapi.io","size":31931,"stargazers_count":3351,"watchers_count":3351,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":252,"mirror_url":null,"archived":false,"open_issues_count":48,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":252,"open_issues":48,"watchers":3351,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/strapi/strapi/pulls/671"},"html":{"href":"https://github.com/strapi/strapi/pull/671"},"issue":{"href":"https://api.github.com/repos/strapi/strapi/issues/671"},"comments":{"href":"https://api.github.com/repos/strapi/strapi/issues/671/comments"},"review_comments":{"href":"https://api.github.com/repos/strapi/strapi/pulls/671/comments"},"review_comment":{"href":"https://api.github.com/repos/strapi/strapi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/strapi/strapi/pulls/671/commits"},"statuses":{"href":"https://api.github.com/repos/strapi/strapi/statuses/37d00cae42dacdcbe55d96300c91c6e07873d345"}},"author_association":"OWNER"}}
{"actor":{"display_login":"Aurelsicoko"}}