joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

can not find the file on android #658

Closed nikhilbhawsinka closed 3 years ago

nikhilbhawsinka commented 3 years ago

Have a base 64 from which i want to convert to PDF. I am using run time permission in the following way:

    console.log(pdflocation_2)
    try {
        const granted = await PermissionsAndroid.request(
            PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
            {
                title: "Give me permission",
                message:
                "I need permission ",
                buttonNeutral: "Ask Me Later",
                buttonNegative: "Cancel",
                buttonPositive: "OK"
            }
        );
        if (granted === PermissionsAndroid.RESULTS.GRANTED) {
            RNFetchBlob.fs.writeFile(pdflocation_2,base64data, 'base64')
                .then((res) => {console.log("File : ", res)});
        } else {
            console.log("Permission denied");
        }
    } catch (err) {
        console.warn(err);
    }
}; 

Calling this function by passing a location obtained by let pdfLocation = RNFetchBlob.fs.dirs.CacheDir + '/' + 'test.pdf'; and a base64 which i have from my backend. The location obtained looks like: /data/user/0/com.billinvoicenew/cache/test.pdf, and the response of .then((res) => {console.log("File : ", res)}) is File : 15363 which means the file has been created but can not find the file on my mobile. Base64 is correct have validated it online. Please help

nikhilbhawsinka commented 3 years ago

I have also tried let pdflocation_2 = RNFetchBlob.fs.dirs.DownloadDir + '/' + 'invoicetest.pdf';, the location is /storage/emulated/0/Download/invoicetest.pdf but still cant find the pdf

olup commented 3 years ago

What did you do to resolve your problem ?

wanderlust252 commented 3 years ago

i have this issue too

babyrusa commented 2 years ago

It's not in the Download folder. I clicked around and found them in Files > device name > DCIM