I am working on a react-native project in which I need to download some image files from the server and save them inside the App. These must be saved in the internal private storage of the App such that the app user must not be able to find these files (in non-rooted phone). I have searched on google and found the below options:
Please suggest a simple way to download image[ or other format] file in the react native app which must be inside App's private data folder without any conversion into string or any other medium.
You can use Document Directory
as path to save your files. It keeps the files inside the storage of application which you want and when you want to retrieve the files, then you already knows the base path and you just need to supply the filename to access the file.
const dirs = RNFetchBlob.fs.dirs;
RNFetchBlob
.config({
path : dirs.DocumentDir + `${folder_name}/${filename}`
}).fetch('GET', `${fileURL}`).progress((received=0, total=0) => {
//Handle progress of download here.. May be update UI...
}).then((resp) => {
//You can get the path of the file saved using resp.path()
.catch((err) => {
//Handle error here...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With