Node.js - how to receive and parse multipart/formData as array of objects with fields and files?
Asked Answered
H

0

7

I want to do the implementation to receive multipart/formData in my Node.js server application. For this kind of request, I should be able to receive array of fields for same "key" in form and array of files on same "key" in multipart but at different indexes.

For example: My formData (fields) should looks like this (key:value) at client side application:

data[0].id : 1
data[0].name : Data 1
data[1].id : 2
data[1].name : Data 2

My multipart form (files) should looks like this (key:value) at client side application:

data[0].images[0] : "/file1_path.jpg"
data[0].images[1] : "/file2_path.jpg"
data[1].images[0] : "/file3_path.jpg"
data[1].images[1] : "/file4_path.jpg"

This request is basically to upload all data of an array of objects from client application and object will contain text datas and images array. I can receive this data and able to parse data and files.

For UrlEncoded-formData, I'm using 'body-parser' module with 'express' module.

Is there any node module to achieve above requirements?

If I want to hit this request via Postman then it will look like this: Request from Postman

Handspring answered 27/2, 2019 at 9:22 Comment(1)
Did you find solution ?Strobila

© 2022 - 2024 — McMap. All rights reserved.