javascript - Node.js File Upload doesn't work -


i need post image external service.

if use client postman test upload manually works perfectly.

i have make post , supply body form-data , key picture image. post request postman

but doesn't work if i'm posting node app. i'm using request module handling requests.

const formdata = { picture: fs.createreadstream('./path/to/image') }  request.post({url: "http://example.com", formdata: formdata}, function(err, res, body) {   console.log(body) } 

the log says {"code":400,"exception":"the file failed upload.} since external service can't more information error.

i need replicate request make postman. how it? don't care module use requests.

when sending file consider using stream post action, example:

const options = {     method: 'post',     url: "www.someurl.com" }; const req = request(options, callback); const form = req.form(); form.append('image', fs.createreadstream(file_path)); 

is possible sending file before read action finished?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -