{"action":"created","issue":{"url":"https://api.github.com/repos/balderdashy/sails/issues/4364","repository_url":"https://api.github.com/repos/balderdashy/sails","labels_url":"https://api.github.com/repos/balderdashy/sails/issues/4364/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/sails/issues/4364/comments","events_url":"https://api.github.com/repos/balderdashy/sails/issues/4364/events","html_url":"https://github.com/balderdashy/sails/issues/4364","id":315264096,"number":4364,"title":"Sails not detecting multiple file upload","user":{"login":"LiamMartens","id":5265324,"avatar_url":"https://avatars0.githubusercontent.com/u/5265324?v=4","gravatar_id":"","url":"https://api.github.com/users/LiamMartens","html_url":"https://github.com/LiamMartens","followers_url":"https://api.github.com/users/LiamMartens/followers","following_url":"https://api.github.com/users/LiamMartens/following{/other_user}","gists_url":"https://api.github.com/users/LiamMartens/gists{/gist_id}","starred_url":"https://api.github.com/users/LiamMartens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LiamMartens/subscriptions","organizations_url":"https://api.github.com/users/LiamMartens/orgs","repos_url":"https://api.github.com/users/LiamMartens/repos","events_url":"https://api.github.com/users/LiamMartens/events{/privacy}","received_events_url":"https://api.github.com/users/LiamMartens/received_events","type":"User","site_admin":false},"labels":[{"id":321983834,"url":"https://api.github.com/repos/balderdashy/sails/labels/try%20this%20out%20please","name":"try this out please","color":"009800","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-04-17T22:27:09Z","updated_at":"2018-04-23T18:14:42Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n======================================================\r\nHELLO, and welcome to the (experimental) Sailsbot\r\nissue-submission system.  If you encounter any\r\nproblems with this system, please contact us directly\r\nat http://sailsjs.com/contact.\r\n\r\nFIRST THINGS FIRST: before posting, please carefully\r\nread the contribution guide (http://bit.ly/sails-issue-guide),\r\nparticularly if this is a security issue or an issue of a\r\nnon-technical nature (Github org issues, code of conduct\r\nissues, etc.).  Those should be sent directly at\r\nhttp://sailsjs.com/contact.\r\n\r\nNOW THEN: please fill out the following info\r\n(Don't change text between **)\r\n======================================================\r\n### BEGIN VERSION INFO ###\r\n-->\r\n\r\n**Sails version**: 1.0.1\r\n**Node version**: 9.11.1\r\n**NPM version**: 5.6.0\r\n**DB adapter name**: N/A\r\n**DB adapter version**: N/A\r\n**Operating system**: Alpine Linux \r\n\r\n<!--\r\n### END VERSION INFO ###\r\n======================================================\r\nGREAT! - Now read carefully\r\n(Sailsbot will know if you don't)!\r\n======================================================\r\n\r\nBefore you submit an issue for Sails, please make sure you have read the issue contribution guide (http://bit.ly/sails-issue-guide) carefully, and then verify the following by typing an X in between each set of [ ] brackets below (don't make any other changes to the text!):\r\n\r\n### BEGIN PLEDGE ###\r\n- [X ] I am experiencing a concrete technical issue (aka a bug) with Sails (ideas and feature proposals should follow the guide for proposing features and enhancements (http://bit.ly/sails-feature-guide), which involves making a pull request).  If you're not 100% certain whether it's a bug or not, that's okay--you may continue.  The worst that can happen is that the issue will be closed and we'll point you in the right direction.\r\n\r\n- [ X] I am not asking a question about how to use Sails or about whether or not Sails has a certain feature (please refer to the documentation(http://sailsjs.com), or post on http://stackoverflow.com, our Google Group (http://bit.ly/sails-google-group) or our live chat (https://gitter.im/balderdashy/sails).\r\n\r\n- [ X] I have already searched for related issues, and found none open (if you found a related _closed_ issue, please link to it in your post).\r\n\r\n- [ X] My issue title is concise, on-topic and polite (\"jst.js being removed from layout.ejs on lift\" is good; \"templates dont work\" or \"why is sails dumb\" are not so good).\r\n\r\n- [ X] I have tried all the following (if relevant) and my issue remains:\r\n  - Make sure you have the right app lifted.\r\n  - Make sure you've killed the Sails server with CTRL+C and started it again.\r\n  - Make sure you closed any open browser tabs pointed at localhost before starting Sails.\r\n  - Make sure you do not have any other Sails apps running in other terminal windows.\r\n  - Make sure the app you are using to reproduce the issue has a clean node_modules/ directory, meaning:\r\n    * no dependencies are linked (e.g. you haven't run npm link foo)\r\n    * that you haven't made any inline changes to files in the node_modules/ folder\r\n    * that you don't have any weird global dependency loops. The easiest way to double-check any of the above, if you aren't sure, is to run: rm -rf node_modules && npm cache clear && npm install.\r\n\r\nand finally...\r\n- [X ] **I can provide steps to reproduce this issue that others can follow.**\r\n\r\nIdeally, this involves creating a new repo that demonstrates the problem (see instructions at http://bit.ly/sails-issue-repro).  Even though your issue may seem so simple to reproduce that a new repo is unnecessary, you'd be surprised how many solutions present themselves when you start from `sails new` and attempt to recreate your issue from scratch in a new app.  This ensures that the real issue isn't in your user code (a forgotten policy file, perhaps?) or in a third-party module.  If you're absolutely _convinced_ that a new repo is unnecessary, provide clear, concise and _specific_ steps to reproduce the problem in your post (not \"create a model then do blueprint create\").\r\n### END PLEDGE ###\r\n\r\nOKAY--THANKS FOR READING!  Continue posting details of your issue below. -->\r\n<hr/>\r\n\r\nIt appears sails is not handling the body parsing correctly when trying to upload multiple files. Either when uploading more than 1 file with different keys or when uploading an array of files. I have tried so using [Insomnia REST client](https://insomnia.rest/) but also using raw cURL requests as detailed below.\r\n\r\nEither way I am never able to retrieve the 2nd (or subsequent file) using the `this.req.file('fieldName')` in a controller action, or the file array only contains 1 raw file (`this.req.file('field')._files`)\r\n\r\n*Note* I did send the text fields before the file fields as detailed in the documentation\r\n\r\n**Example cURL**\r\n```\r\ncurl -X POST -F \"name=someName\" -F \"image=@/path/to/image\" -F \"other=@/path/to/other\" http://localhost:1337/upload\r\n```\r\nThis results in only being able to get a file in `this.req.file('image')`.\r\n\r\n```\r\ncurl -X POST -F \"name=someName\" -F \"image[]=@/path/to/image\" -F \"image[]=@/path/to/other\" http://localhost:1337/upload\r\n```\r\nThis results in getting no files in `this.req.file('image')._files` and only getting 1 file in `this.req.file('image[]')._files`.\r\n"},"comment":{"url":"https://api.github.com/repos/balderdashy/sails/issues/comments/383671727","html_url":"https://github.com/balderdashy/sails/issues/4364#issuecomment-383671727","issue_url":"https://api.github.com/repos/balderdashy/sails/issues/4364","id":383671727,"user":{"login":"mikermcneil","id":618009,"avatar_url":"https://avatars3.githubusercontent.com/u/618009?v=4","gravatar_id":"","url":"https://api.github.com/users/mikermcneil","html_url":"https://github.com/mikermcneil","followers_url":"https://api.github.com/users/mikermcneil/followers","following_url":"https://api.github.com/users/mikermcneil/following{/other_user}","gists_url":"https://api.github.com/users/mikermcneil/gists{/gist_id}","starred_url":"https://api.github.com/users/mikermcneil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikermcneil/subscriptions","organizations_url":"https://api.github.com/users/mikermcneil/orgs","repos_url":"https://api.github.com/users/mikermcneil/repos","events_url":"https://api.github.com/users/mikermcneil/events{/privacy}","received_events_url":"https://api.github.com/users/mikermcneil/received_events","type":"User","site_admin":false},"created_at":"2018-04-23T18:14:41Z","updated_at":"2018-04-23T18:14:41Z","author_association":"OWNER","body":"@LiamMartens Actually, re-reading your issue, I'm not sure this is the problem.  You'll need to wait until `req.file(…).upload(…)` is complete -- i.e. in the callback -- before checking what files were uploaded.\r\n\r\nHere's an example using async/await from the [recent Sails 1.0 tutorial course](platzi.com/clases/javascript-pro/):\r\nhttps://github.com/mikermcneil/ration/blob/b8ed92ceb8f49493a984392c92141274e2e0152e/api/controllers/things/upload-thing.js#L53-L60"}}
{"actor":{"display_login":"mikermcneil"}}