{"action":"created","comment":{"url":"https://api.github.com/repos/Syncano/syncano-node/pulls/comments/172173754","pull_request_review_id":101141493,"id":172173754,"diff_hunk":"@@ -0,0 +1,130 @@\n+# File upload using data objects\n+\n+* Preparation: **5 minutes**\n+* Requirements:\n+  * Initiated Syncano project\n+\n+### Problem to solve\n+\n+You want to upload file to the database.\n+\n+### Solution\n+\n+You'll have to create form with upload field and socket to handle it.\n+\n+\n+#### Create socket\n+\n+At first you need to create a socket. Go to your project's directory with initiated syncano project and type:\n+\n+```sh\n+npx s create application\n+```\n+\n+Syncano has `file` type created for storage. You have to create a data class with this type in your `syncano/application/socket.yml` file.\n+\n+```\n+name: application\n+description: Description of application\n+version: 0.0.1\n+runtime: nodejs_v8\n+\n+classes:\n+  files:\n+    - name: file\n+      type: file\n+\n+endpoints:\n+  upload: \n+    description: add new file\n+    parameters: \n+      file: \n+        type: file\n+        description: application info\n+    response:\n+      success: \n+        description: Success\n+        example:\n+          {\n+            \"msg\": \"uploaded ok\"\n+          }\n+      fail:\n+        exit_code: 400\n+        description: Failed\n+        parameters:\n+          message:\n+            description: Error message\n+\n+```\n+\n+Next you need to install `form-data` package using `npm install -D form-data` inside of your socket directory. After that, in your endpoint (`upload.js`) you can to handle the file using it.\n+\n+```js\n+import Syncano from '@syncano/core'\n+import FormData from 'form-data'\n+\n+export default (ctx) => {\n+  const {data, response} = new Syncano(ctx)\n+\n+  if (ctx.args.file) {\n+    const form = new FormData() \n+    form.append('file', ctx.args.file, {","path":"docs/cookbook/web/basics/file-upload.md","position":71,"original_position":71,"commit_id":"16f184fb0c84c7bc8ba80898c0b28d444f759b3c","original_commit_id":"16f184fb0c84c7bc8ba80898c0b28d444f759b3c","user":{"login":"adamwardecki","id":1017097,"avatar_url":"https://avatars1.githubusercontent.com/u/1017097?v=4","gravatar_id":"","url":"https://api.github.com/users/adamwardecki","html_url":"https://github.com/adamwardecki","followers_url":"https://api.github.com/users/adamwardecki/followers","following_url":"https://api.github.com/users/adamwardecki/following{/other_user}","gists_url":"https://api.github.com/users/adamwardecki/gists{/gist_id}","starred_url":"https://api.github.com/users/adamwardecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamwardecki/subscriptions","organizations_url":"https://api.github.com/users/adamwardecki/orgs","repos_url":"https://api.github.com/users/adamwardecki/repos","events_url":"https://api.github.com/users/adamwardecki/events{/privacy}","received_events_url":"https://api.github.com/users/adamwardecki/received_events","type":"User","site_admin":false},"body":"```\r\nconst {file, filename, filetype} = ctx.args\r\n...\r\n\r\n  form.append('file', file, { filename, filetype })\r\n```","created_at":"2018-03-05T12:39:15Z","updated_at":"2018-03-05T12:41:14Z","html_url":"https://github.com/Syncano/syncano-node/pull/176#discussion_r172173754","pull_request_url":"https://api.github.com/repos/Syncano/syncano-node/pulls/176","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/Syncano/syncano-node/pulls/comments/172173754"},"html":{"href":"https://github.com/Syncano/syncano-node/pull/176#discussion_r172173754"},"pull_request":{"href":"https://api.github.com/repos/Syncano/syncano-node/pulls/176"}}},"pull_request":{"url":"https://api.github.com/repos/Syncano/syncano-node/pulls/176","id":171366759,"html_url":"https://github.com/Syncano/syncano-node/pull/176","diff_url":"https://github.com/Syncano/syncano-node/pull/176.diff","patch_url":"https://github.com/Syncano/syncano-node/pull/176.patch","issue_url":"https://api.github.com/repos/Syncano/syncano-node/issues/176","number":176,"state":"open","locked":false,"title":"Docs/cookbook upload","user":{"login":"maciejkorsan","id":655235,"avatar_url":"https://avatars0.githubusercontent.com/u/655235?v=4","gravatar_id":"","url":"https://api.github.com/users/maciejkorsan","html_url":"https://github.com/maciejkorsan","followers_url":"https://api.github.com/users/maciejkorsan/followers","following_url":"https://api.github.com/users/maciejkorsan/following{/other_user}","gists_url":"https://api.github.com/users/maciejkorsan/gists{/gist_id}","starred_url":"https://api.github.com/users/maciejkorsan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciejkorsan/subscriptions","organizations_url":"https://api.github.com/users/maciejkorsan/orgs","repos_url":"https://api.github.com/users/maciejkorsan/repos","events_url":"https://api.github.com/users/maciejkorsan/events{/privacy}","received_events_url":"https://api.github.com/users/maciejkorsan/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-26T12:55:43Z","updated_at":"2018-03-05T12:41:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bd6bbc9695d909072b7c95e6a37cc189e796107","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Syncano/syncano-node/pulls/176/commits","review_comments_url":"https://api.github.com/repos/Syncano/syncano-node/pulls/176/comments","review_comment_url":"https://api.github.com/repos/Syncano/syncano-node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Syncano/syncano-node/issues/176/comments","statuses_url":"https://api.github.com/repos/Syncano/syncano-node/statuses/16f184fb0c84c7bc8ba80898c0b28d444f759b3c","head":{"label":"Syncano:docs/cookbook-upload","ref":"docs/cookbook-upload","sha":"16f184fb0c84c7bc8ba80898c0b28d444f759b3c","user":{"login":"Syncano","id":6367703,"avatar_url":"https://avatars2.githubusercontent.com/u/6367703?v=4","gravatar_id":"","url":"https://api.github.com/users/Syncano","html_url":"https://github.com/Syncano","followers_url":"https://api.github.com/users/Syncano/followers","following_url":"https://api.github.com/users/Syncano/following{/other_user}","gists_url":"https://api.github.com/users/Syncano/gists{/gist_id}","starred_url":"https://api.github.com/users/Syncano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Syncano/subscriptions","organizations_url":"https://api.github.com/users/Syncano/orgs","repos_url":"https://api.github.com/users/Syncano/repos","events_url":"https://api.github.com/users/Syncano/events{/privacy}","received_events_url":"https://api.github.com/users/Syncano/received_events","type":"Organization","site_admin":false},"repo":{"id":108282909,"name":"syncano-node","full_name":"Syncano/syncano-node","owner":{"login":"Syncano","id":6367703,"avatar_url":"https://avatars2.githubusercontent.com/u/6367703?v=4","gravatar_id":"","url":"https://api.github.com/users/Syncano","html_url":"https://github.com/Syncano","followers_url":"https://api.github.com/users/Syncano/followers","following_url":"https://api.github.com/users/Syncano/following{/other_user}","gists_url":"https://api.github.com/users/Syncano/gists{/gist_id}","starred_url":"https://api.github.com/users/Syncano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Syncano/subscriptions","organizations_url":"https://api.github.com/users/Syncano/orgs","repos_url":"https://api.github.com/users/Syncano/repos","events_url":"https://api.github.com/users/Syncano/events{/privacy}","received_events_url":"https://api.github.com/users/Syncano/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Syncano/syncano-node","description":"Syncano Toolkit for JavaScript development","fork":false,"url":"https://api.github.com/repos/Syncano/syncano-node","forks_url":"https://api.github.com/repos/Syncano/syncano-node/forks","keys_url":"https://api.github.com/repos/Syncano/syncano-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Syncano/syncano-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Syncano/syncano-node/teams","hooks_url":"https://api.github.com/repos/Syncano/syncano-node/hooks","issue_events_url":"https://api.github.com/repos/Syncano/syncano-node/issues/events{/number}","events_url":"https://api.github.com/repos/Syncano/syncano-node/events","assignees_url":"https://api.github.com/repos/Syncano/syncano-node/assignees{/user}","branches_url":"https://api.github.com/repos/Syncano/syncano-node/branches{/branch}","tags_url":"https://api.github.com/repos/Syncano/syncano-node/tags","blobs_url":"https://api.github.com/repos/Syncano/syncano-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Syncano/syncano-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Syncano/syncano-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/Syncano/syncano-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Syncano/syncano-node/statuses/{sha}","languages_url":"https://api.github.com/repos/Syncano/syncano-node/languages","stargazers_url":"https://api.github.com/repos/Syncano/syncano-node/stargazers","contributors_url":"https://api.github.com/repos/Syncano/syncano-node/contributors","subscribers_url":"https://api.github.com/repos/Syncano/syncano-node/subscribers","subscription_url":"https://api.github.com/repos/Syncano/syncano-node/subscription","commits_url":"https://api.github.com/repos/Syncano/syncano-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/Syncano/syncano-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/Syncano/syncano-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/Syncano/syncano-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/Syncano/syncano-node/contents/{+path}","compare_url":"https://api.github.com/repos/Syncano/syncano-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Syncano/syncano-node/merges","archive_url":"https://api.github.com/repos/Syncano/syncano-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Syncano/syncano-node/downloads","issues_url":"https://api.github.com/repos/Syncano/syncano-node/issues{/number}","pulls_url":"https://api.github.com/repos/Syncano/syncano-node/pulls{/number}","milestones_url":"https://api.github.com/repos/Syncano/syncano-node/milestones{/number}","notifications_url":"https://api.github.com/repos/Syncano/syncano-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Syncano/syncano-node/labels{/name}","releases_url":"https://api.github.com/repos/Syncano/syncano-node/releases{/id}","deployments_url":"https://api.github.com/repos/Syncano/syncano-node/deployments","created_at":"2017-10-25T14:38:15Z","updated_at":"2018-02-14T11:52:34Z","pushed_at":"2018-03-03T18:16:22Z","git_url":"git://github.com/Syncano/syncano-node.git","ssh_url":"git@github.com:Syncano/syncano-node.git","clone_url":"https://github.com/Syncano/syncano-node.git","svn_url":"https://github.com/Syncano/syncano-node","homepage":"https://syncano.io","size":3300,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":57,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":57,"watchers":5,"default_branch":"master"}},"base":{"label":"Syncano:master","ref":"master","sha":"ee3476b37d0b7e88694a60be150cbedccd3a7411","user":{"login":"Syncano","id":6367703,"avatar_url":"https://avatars2.githubusercontent.com/u/6367703?v=4","gravatar_id":"","url":"https://api.github.com/users/Syncano","html_url":"https://github.com/Syncano","followers_url":"https://api.github.com/users/Syncano/followers","following_url":"https://api.github.com/users/Syncano/following{/other_user}","gists_url":"https://api.github.com/users/Syncano/gists{/gist_id}","starred_url":"https://api.github.com/users/Syncano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Syncano/subscriptions","organizations_url":"https://api.github.com/users/Syncano/orgs","repos_url":"https://api.github.com/users/Syncano/repos","events_url":"https://api.github.com/users/Syncano/events{/privacy}","received_events_url":"https://api.github.com/users/Syncano/received_events","type":"Organization","site_admin":false},"repo":{"id":108282909,"name":"syncano-node","full_name":"Syncano/syncano-node","owner":{"login":"Syncano","id":6367703,"avatar_url":"https://avatars2.githubusercontent.com/u/6367703?v=4","gravatar_id":"","url":"https://api.github.com/users/Syncano","html_url":"https://github.com/Syncano","followers_url":"https://api.github.com/users/Syncano/followers","following_url":"https://api.github.com/users/Syncano/following{/other_user}","gists_url":"https://api.github.com/users/Syncano/gists{/gist_id}","starred_url":"https://api.github.com/users/Syncano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Syncano/subscriptions","organizations_url":"https://api.github.com/users/Syncano/orgs","repos_url":"https://api.github.com/users/Syncano/repos","events_url":"https://api.github.com/users/Syncano/events{/privacy}","received_events_url":"https://api.github.com/users/Syncano/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Syncano/syncano-node","description":"Syncano Toolkit for JavaScript development","fork":false,"url":"https://api.github.com/repos/Syncano/syncano-node","forks_url":"https://api.github.com/repos/Syncano/syncano-node/forks","keys_url":"https://api.github.com/repos/Syncano/syncano-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Syncano/syncano-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Syncano/syncano-node/teams","hooks_url":"https://api.github.com/repos/Syncano/syncano-node/hooks","issue_events_url":"https://api.github.com/repos/Syncano/syncano-node/issues/events{/number}","events_url":"https://api.github.com/repos/Syncano/syncano-node/events","assignees_url":"https://api.github.com/repos/Syncano/syncano-node/assignees{/user}","branches_url":"https://api.github.com/repos/Syncano/syncano-node/branches{/branch}","tags_url":"https://api.github.com/repos/Syncano/syncano-node/tags","blobs_url":"https://api.github.com/repos/Syncano/syncano-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Syncano/syncano-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Syncano/syncano-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/Syncano/syncano-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Syncano/syncano-node/statuses/{sha}","languages_url":"https://api.github.com/repos/Syncano/syncano-node/languages","stargazers_url":"https://api.github.com/repos/Syncano/syncano-node/stargazers","contributors_url":"https://api.github.com/repos/Syncano/syncano-node/contributors","subscribers_url":"https://api.github.com/repos/Syncano/syncano-node/subscribers","subscription_url":"https://api.github.com/repos/Syncano/syncano-node/subscription","commits_url":"https://api.github.com/repos/Syncano/syncano-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/Syncano/syncano-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/Syncano/syncano-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/Syncano/syncano-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/Syncano/syncano-node/contents/{+path}","compare_url":"https://api.github.com/repos/Syncano/syncano-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Syncano/syncano-node/merges","archive_url":"https://api.github.com/repos/Syncano/syncano-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Syncano/syncano-node/downloads","issues_url":"https://api.github.com/repos/Syncano/syncano-node/issues{/number}","pulls_url":"https://api.github.com/repos/Syncano/syncano-node/pulls{/number}","milestones_url":"https://api.github.com/repos/Syncano/syncano-node/milestones{/number}","notifications_url":"https://api.github.com/repos/Syncano/syncano-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Syncano/syncano-node/labels{/name}","releases_url":"https://api.github.com/repos/Syncano/syncano-node/releases{/id}","deployments_url":"https://api.github.com/repos/Syncano/syncano-node/deployments","created_at":"2017-10-25T14:38:15Z","updated_at":"2018-02-14T11:52:34Z","pushed_at":"2018-03-03T18:16:22Z","git_url":"git://github.com/Syncano/syncano-node.git","ssh_url":"git@github.com:Syncano/syncano-node.git","clone_url":"https://github.com/Syncano/syncano-node.git","svn_url":"https://github.com/Syncano/syncano-node","homepage":"https://syncano.io","size":3300,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":57,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":57,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Syncano/syncano-node/pulls/176"},"html":{"href":"https://github.com/Syncano/syncano-node/pull/176"},"issue":{"href":"https://api.github.com/repos/Syncano/syncano-node/issues/176"},"comments":{"href":"https://api.github.com/repos/Syncano/syncano-node/issues/176/comments"},"review_comments":{"href":"https://api.github.com/repos/Syncano/syncano-node/pulls/176/comments"},"review_comment":{"href":"https://api.github.com/repos/Syncano/syncano-node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Syncano/syncano-node/pulls/176/commits"},"statuses":{"href":"https://api.github.com/repos/Syncano/syncano-node/statuses/16f184fb0c84c7bc8ba80898c0b28d444f759b3c"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"adamwardecki"}}