我需要下载一个文件(.pdf),这是来自flask rest API的代码
return send_file(file_location, as_attachment=True)我试着使用RNFetchBlob
RNFetchBlob
.config({
addAndroidDownloads: {
useDownloadManager: true, // <-- this is the only thing required
// Optional, override notification setting (default to true)
notification: false,
// Optional, but recommended since android DownloadManager will fail when
// the url does not contains a file extension, by default the mime type will be text/plain
mime: 'application/pdf',
description: 'File downloaded by download manager.',
},
})
.fetch('POST', 'http://192.168.0.199:8000/v1/quote/view', data)
.then((res)=>console.log('The file saved to ', res.path()))
.catch((err)=>console.log(err));但是,即使我在flask中提到POST方法,它也是作为GET方法接收的
192.168.0.186 - - [11/Aug/2021 19:05:31] "GET /v1/quote/view HTTP/1.1" 405 -我做错了什么?
发布于 2021-08-11 14:49:39
感谢@Xhirazi,
fetch(方法、URL、headers、body)的顺序应该是这样的,修复了这个问题
https://stackoverflow.com/questions/68743240
复制相似问题