I have the following function to download a PDF from my server:
const downloadInvoice = (invoiceId) => {
const path = `${RNFetchBlob.fs.dirs.DocumentDir}/${invoiceId}.pdf`;
RNFetchBlob.config({
fileCache: true,
path,
}).fetch('GET', `${Urls.base}/pro/invoice?invoiceId=${invoiceId}`, {
...authorizationHeaders
}).then((response) => {
RNFetchBlob.ios.openDocument(path);
}).catch((error) => {
Alert.alert(error);
});
};
When I run this code, the document opens up on my iPhone and I can see the PDF file. The problem is, I cant find the PDF document anywhere after I close the window. It seems like the document is stored in cache, but I want it to store in a folder accessible on my iPhone for later user (or to print it or transfer it to my laptop).
Path looks like: /var/mobile/Containers/Data/Application/AD1F85AC-456F-321A-A4B2-1B248F1134C1/Documents/20-02-2020-01-02.pdf
. Also, when I console.log response.path(), it has the same path.
I'm using rn-fetch-blod, but I see this package is unmaintained. If somebody has a good alternative, I'm happy to hear it.
add this keys in
info.plist
foriOS
source : https://github.com/joltup/rn-fetch-blob/issues/212