As it says in the documentation that the PictureDir is only available in Android.
https://github.com/joltup/rn-fetch-blob/wiki/File-System-Access-API#dirs
DocumentDir
CacheDir
MainBundleDir (Can be used to access files embedded on iOS apps only)
DCIMDir (Android Only)
DownloadDir (Android Only)
MusicDir (Android Only)
PictureDir (Android Only)
MovieDir (Android Only)
RingtoneDir (Android Only)
SDCardDir (0.9.5+ Android Only)
You should use DocumentDir
or CacheDir
to save files on iOS
You could do something like this which will allow you to use different directories depending on the OS
import { Platform } from 'react-native';
...
let PictureDir = Platform.OS === 'ios' ? fs.dirs.DocumentDir : fs.dirs.PictureDir;
Update
I tried out your updated code and it works, however I did have to make one tweak to it.
When you use the addAndroidDownloads
you have to be aware that you cannot set your own path for Android.
When using DownloadManager, fileCache and path properties in config
will not take effect, because Android DownloadManager can only store
files to external storage, also notice that Download Manager can only
support GET method, which means the request body will be ignored.
https://github.com/joltup/rn-fetch-blob#android-media-scanner-and-download-manager-support
So to set the path so that iOS knows where to store the file you should set the path outside that addAndroidDownloads
object so that your options become:
let options = {
fileCache: true,
addAndroidDownloads : {
useDownloadManager : true, // setting it to true will use the device's native download manager and will be shown in the notification bar.
notification : false,
description : 'Downloading image.'
},
path: PictureDir + "/me_"+Math.floor(date.getTime() + date.getSeconds() / 2) // this is the path where your downloaded file will live in
}
For iOS it will ignore the settings in addAndroidDownloads
and the file will be saved in the documents directory on the device, as that is the path that is given.
If you are wanting to save the file into the photo gallery of the device on iOS then you will have to look into using CameraRoll
You can see an answer that I gave on how to use that here https://stackoverflow.com/a/54125033/5508175