1

我需要通过代码下载来自flask rest API的文件(.pdf)

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));

但即使我在烧瓶中提到 POST 方法,它也会作为 GET 方法接收

192.168.0.186 - - [11/Aug/2021 19:05:31] "GET /v1/quote/view HTTP/1.1" 405 -

我究竟做错了什么?

4

1 回答 1

1

谢谢@Xhirazi,

顺序应该是这样的 fetch(Method, URL, headers, body),解决了这个问题

于 2021-08-11T14:49:38.947 回答