I'm trying to post a file to a remote URL using npm got. But it is not working as expected.
I have tried the following
const headers = {
"Content-Type": "image/png"
}
const requestProperties = {
method: 'POST',
url,
headers,
json: fs.createReadStream(file.path)
}
const response = await got(requestProperties);
Thank you!
Thank you @phil I have used body property instead of json.
const headers = {
"Content-Type": "image/png"
}
const requestProperties = {
method: 'POST',
url,
headers,
body: fs.createReadStream(file.path)
}
const response = await got(requestProperties);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.