multer
multer copied to clipboard
Multer - Upload Files form child object
I have a User object in my application, where each user Object has a Nominee as a child object With a File field name photo
.
JSON Object
{
name: 'Jhon Doe',
phone: '01548761645',
email: '[email protected]',
photo: File(),
nominee: {
name: 'Nominee name',
phone: '9876546542',
photo: File()
}
}
In Express
app.post(upload.fields([{name:'photo'}, {name:'nominee'}]), function(req, res) {
res.send(req.files['photo']); // send file details
res.send(req.files['nominee']); // did not show any file details
}
In my express code i can access all file details for Parent
Object but it did not show any details for child(nominee) Object. Is there anything wrong in my code or multer
did not support nested child field..?
How are you sending the data over the wire? Maybe the second name is actually nominee.photo
?
Thank you for your response. i tried all possible way but didn't not work. i think multer is not support child object file upload.
hi @rahadur it does, did you find a way around this
Hello, I'm struggling with a similiar situation. It's not very straight forward of how to access values from child objects.
@rahadur Can you provide the client side form which you used ?? So that I can recreate the issue.
Any solution for this yet? currently having the same challenge
How is your data formatted over the wire? I.e. how are you sending it from your front end?
Without this information I can't tell if or how we would support this...