M
M
Mikhailo Poberezhny2016-06-08 00:33:58
Node.js
Mikhailo Poberezhny, 2016-06-08 00:33:58

How to parse such an object?

{ file: 
   { data: <Buffer ff d8 ff e1 24 b4 45 78 69 66 00 00 49 49 2a 00 08 00 00 00 10 00 00 01 03 00 01 00 00 00 40 14 00 00 01 01 03 00 01 00 00 00 80 0d 00 00 02 01 03 00 ... >,
     name: '1_607.jpg',
     encoding: '7bit',
     mimetype: 'image/jpeg',
     truncated: false,
     size: 265201 } }
{ file: 
   { data: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 00 48 00 48 00 00 ff db 00 43 00 04 03 03 04 03 03 04 04 03 04 05 04 04 05 06 0a 07 06 06 06 06 0d 09 0a 08 ... >,
     name: '9AkFnM9BAKM.jpg',
     encoding: '7bit',
     mimetype: 'image/jpeg',
     truncated: false,
     size: 125595 } }
{ file: 
   { data: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 43 00 06 04 05 06 05 04 06 06 05 06 07 07 06 08 0a 10 0a 0a 09 09 0a 14 0e 0f 0c ... >,
     name: '72_main.jpg',
     encoding: '7bit',
     mimetype: 'image/jpeg',
     truncated: false,
     size: 9924 } }

This is not an array, these 3 files come to me in this way. I can't access the index ala req.files[0]...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Kayun, 2016-06-08
@Kayun

After the bodyParser middleware, res.body should have this object. Well, actually write data to the file as a stream.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question