I'm trying to download and save files in the file system like how WhatsApp does it.
WhatsApp stores files inside android/media/com.whatsapp/
.
I was able to download and save the file inside /data/user/0/com.packagename/files
using this library. I tried DocumentDir
and PictureDir
.
let dirs = ReactNativeBlobUtil.fs.dirs
ReactNativeBlobUtil
.config({
// response data will be saved to this path if it has access right.
path: dirs.DocumentDir + '/path-to-file.anything'
})
.fetch('GET', 'http://www.example.com/file/example.zip', {
//some headers ..
})
.then((res) => {
// the path should be dirs.DocumentDir + 'path-to-file.anything'
console.log('The file saved to ', res.path())
})
Is there a way I can save them inside media
folder instead of data
?
I checked mediastore and other areas, but couldn't find a decent answer. Look into react-native-fs but couldn't find anything useful
Find more details here: https://github.com/RonRadtke/react-native-blob-util/issues/305
Step 1 Create a package named folder inside the Android/media folder
Example:
Step 2 Save the file to a specific path
Example:
I used react native share for ios file downloading