richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

Single file upload req.body parse? #229

Closed dalisoft closed 4 years ago

dalisoft commented 4 years ago

Hi.

Thanks for very good middleware, but can you fix bug where single upload req.body[field] does not income as Array, even appending [] does not help.

Send file + field form.append('tags[]', 'foo') gets req.body.tags[] as string

RomanBurunkov commented 4 years ago

Hi @dalisoft ,

Could u clarify how parsing fields relates to the express-fileupload? It only looks into fields with multipart data and store it in req.files.

I believe other fields should be parsed with something else. E.g. bodyparser.

dalisoft commented 4 years ago

I am using body-parser. It is works if i am using application/json. But only for file upload i using express-fileupload but express-file upload does not gets as Array when fole is single

RomanBurunkov commented 4 years ago

The description is still vague.

You mentioned the following body property 'req.body.tags', but express-fileupload creates only req.files property.

If you have several files for the same field name it creates an array of objects. E.g.

req.files.somefield[]

If you have only one file it creates an object: req.files.somefield.

dalisoft commented 4 years ago

I seems i posted wrong here. I try make own middleware. Thanks for replies