D
D
Denis Denis2015-12-09 13:54:31
Node.js
Denis Denis, 2015-12-09 13:54:31

Is it possible to do node/express/multer file upload via Postman?

Whatever one may say, it betrays

Multipart: Boundary not found

I have 3 options:
1. either you can’t upload a file through Postman, although this is nonsense :(
2. Something is wrong in the module settings, although there are 4 lines of everything to copy
. form-data
As I understand it, Boundary is a packet separator,
maybe the browser itself puts this Boundary ?
there is no file property in req
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Denis, 2015-12-09
@golovewkin

I found the answer to my own question.
To upload a file using Postman, you need the field where you upload the file
to have the name that you wrote in the code. Encoding can be omitted

app.post('/profile', upload.single('avatar'), function (req, res, next) {
  console.log (req.headers);
  console.log (req.file);
  // req.file is the `avatar` file
  // req.body will hold the text fields, if there were any
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question