i am using this code to upload image as a property of parent object my server accept image in this form obj["objImg"]["file"] = file.jpg
but this give me error that value of body should be "First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object"
const request = require("request") request({ method: 'POST', uri: hostname + '/thisandthat/420/thisandthat', multipart: [ { body: { obj: { objImg: { file: fs.createReadStream(rootDir + '/temp/image') } } } } ] }, function (err, httpResponse, body) { if (err) { return console.log('err') } console.log('success', body) });
if i will use body: fs.createReadStream(rootDir + '/temp/image')
this will give me 422 because server not accept this structure Image must be inside a object
is there any other method i can use ? can i use Node Default http module ?
Thanks
via Tripurari Shankar
No comments:
Post a Comment