I have a file in local with parameter is file path (example: ./src/fox.jpg).
I want to get file object from this file path to send post to REST API like the image below:
var args = {
data: FileObject from file path
headers: {
"Authorization": `${token}`,
"x-filetype": file.type,
"x-filename": encodeURI(file.name),
"Content-Type": "multipart/form-data"
}
};
client.post("http://...", args, function (data, response) {
// parsed response body as js object
console.log(data);
// raw response
console.log(response);
});
So I used readFile and createReadStream in NodeJS, but it's not working.
How can I do that?
via Tam Vo
No comments:
Post a Comment