1

I'm using react-dropzone to upload multiple files to a Sails.js server. Since react-dropzone gives me the list of dropped files, I'm appending them to a FormData object. With this, when the request hits the server, the req.file('myfile').upload() won't work, since I don't have any input[type=file] on the page and I'm working with AJAX. My question is: Does Skipper have any method to handle FormData uploads or I need to use Multer or something like that?

Matheus Dal'Pizzol
  • 5,735
  • 3
  • 19
  • 29

1 Answers1

1

Well... in the end, I was using FormData the wrong way. If anyone out there aren't seeing the files array in the server, just make sure to not use brackets in the key you append to FormData.

// Incorrect
formdata.append('files[]', file)

// Correct
formdata.append('files', file)
Matheus Dal'Pizzol
  • 5,735
  • 3
  • 19
  • 29
  • Ya apparently arrays are not supported in formdata for salis. Is this an express thing? I have an array of ids i want to send i tried `formdata.append('foo[]', 12); formdata.append('foo[]', 23);` but nothing. did you figure this out ever? – Noitidart Jun 02 '20 at 19:08
  • also formdata cant submit null `formdata.append('description', null)` it makes null a string. – Noitidart Jun 02 '20 at 19:08