0

I have method that upload files to nodeJS. But now, I want to send the files and another data:

 formData.append('files[]', files[i], filename); --> OK

Now, I add this:

formData.append('ORIGIN', origin_array);

I send data like this:

this.http.post(url, formData, options).pipe(map(result => result))

In nodeJS, I am using "multer" library for get files, and it is OK, but I don't know how to get origin item.

In node, I have this code:

module.exports = {
uploadMultimedia: multer({
    storage: storage,
    limits: {
        fieldNameSize: 1 * 1024 * 1024,
        fileSize: 1000 * 1024 * 1024 // 5000MB
    }
}).single('file'),
uploadMultimediaArray: multer({
    storage: storage,
    limits: {
        fieldNameSize: 1 * 1024 * 1024,
        fileSize: 1000 * 1024 * 1024 // 5000MB
    }
}).array('files[]', 10)

}

And this is my API who calls multer:

exports.multimedia = function (req, res) {
  //CODE
 }

Sorry about my english.

John
  • 10,165
  • 5
  • 55
  • 71
oihi08
  • 737
  • 1
  • 6
  • 20
  • Can you post how the code on your node server looks like when you get the post request? I am guessing you can access the `ORIGIN` by doing something like this: `request.getParameter("ORIGIN");` – John Nov 21 '18 at 11:17
  • Maybe this answer can help you? https://stackoverflow.com/questions/4295782/how-do-you-extract-post-data-in-node-js – John Nov 21 '18 at 11:20
  • @John 1 - req.getParameter returns "req.getParameter is not a function" 2- My body is empty :( – oihi08 Nov 21 '18 at 11:26
  • I do not know the exact syntax, but have a look at the answer I linked to. Maybe it can be of help – John Nov 21 '18 at 11:27
  • But I send a FormData not a form – oihi08 Nov 21 '18 at 11:29

0 Answers0