Reputation: 31
i need to download a file(.pdf) which is coming from flask rest API by the code
return send_file(file_location, as_attachment=True)
i tried using 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));
but even when i mentioned POST method in the flask its is received as GET method
192.168.0.186 - - [11/Aug/2021 19:05:31] "GET /v1/quote/view HTTP/1.1" 405 -
What am i doing wrong?
Upvotes: 1
Views: 1595
Reputation: 31
Thanks @Xhirazi,
the order should be like this fetch(Method, URL, headers, body), fixed the issue
Upvotes: 1