Open LiamMartens opened 6 years ago
Hi @LiamMartens! It looks like you missed a step or two when you created your issue. Please edit your comment (use the pencil icon at the top-right corner of the comment box) and fix the following:
As soon as those items are rectified, post a new comment (e.g. “Ok, fixed!”) below and we'll take a look. Thanks!
*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@sailsjs.com
Fixed
@LiamMartens Thanks for posting, we'll take a look as soon as possible.
For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.
@LiamMartens thanks for posting Liam. Would you have a look at https://trello.com/c/WUyTNbx8? (And to a lesser degree, also: https://trello.com/c/WA2Kbtcd)
That should resolve your issue, but let me know if not and I'll take a closer look
@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.
Here's an example using async/await from the recent Sails 1.0 tutorial course.
For multiple files, just change that to var uploads = sails.upload(…)
Also, here's another, more classic example, using callbacks, in case you're not using actions2
@mikermcneil about the callback, I know and the thing is it only uploads 1 file either way. Besides the raw files array req.file(...)._files
also never contains more than a singular file for some reason and it should contain the headers and other metadata from all the files that were uploaded on that key. I believe it is a multipart/form-data parsing issue in Skipper maybe?
Definitely possible- software is a cruel mistress
Would you create a repo that reproduces this and link to it from here?
Sails version: 1.0.1 Node version: 9.11.1 NPM version: 5.6.0 DB adapter name: N/A DB adapter version: N/A Operating system: Alpine Linux
It 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 but also using raw cURL requests as detailed below.
Either 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
)Note I did send the text fields before the file fields as detailed in the documentation
Example cURL
This results in only being able to get a file in
this.req.file('image')
.This results in getting no files in
this.req.file('image')._files
and only getting 1 file inthis.req.file('image[]')._files
.