[英]How to post a file to a remote url using npm got?
我正在嘗試使用 npm 將文件發布到遠程 URL。 但它沒有按預期工作。
我嘗試了以下
const headers = {
"Content-Type": "image/png"
}
const requestProperties = {
method: 'POST',
url,
headers,
json: fs.createReadStream(file.path)
}
const response = await got(requestProperties);
謝謝!
謝謝@phil我使用了 body 屬性而不是 json。
const headers = {
"Content-Type": "image/png"
}
const requestProperties = {
method: 'POST',
url,
headers,
body: fs.createReadStream(file.path)
}
const response = await got(requestProperties);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.