multer icon indicating copy to clipboard operation
multer copied to clipboard

Multer - Upload Files form child object

Open rahadur opened this issue 6 years ago • 7 comments

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..?

rahadur avatar Dec 03 '17 08:12 rahadur

How are you sending the data over the wire? Maybe the second name is actually nominee.photo?

LinusU avatar Dec 04 '17 16:12 LinusU

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.

rahadur avatar Dec 06 '17 06:12 rahadur

hi @rahadur it does, did you find a way around this

radiumrasheed avatar Apr 23 '19 10:04 radiumrasheed

Hello, I'm struggling with a similiar situation. It's not very straight forward of how to access values from child objects.

insivika avatar May 19 '19 20:05 insivika

@rahadur Can you provide the client side form which you used ?? So that I can recreate the issue.

HarshithaKP avatar Oct 09 '19 06:10 HarshithaKP

Any solution for this yet? currently having the same challenge

pryme0 avatar Oct 11 '22 01:10 pryme0

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...

LinusU avatar Oct 11 '22 08:10 LinusU