[英]Corrupted file using request js
我正在使用請求js下載文件。
function requ(){
const options = {
uri: `api/tasks/${id}/attachments/${attachmentId}`
}
return rp.get(options)
}
我的問題是:
為什么用管道傳遞給像requ()。pipe(res)這樣的“ res”,並使用“ send”返回上述請求的結果
requ().then((result)=>{
//here result is the file's representing string
res.send(result)
})
別?
我的文件已損壞,因為請求將響應正文轉換為utf8。 使用方法:
const options = {
uri: `api/tasks/${id}/attachments/${attachmentId}`,
encoding:null
}
解決了問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.