I am using react native cameraroll api to save my images in storage.
CameraRoll.saveToCameraRoll(data.uri)
.then(console.log('Success', 'Photo added to camera roll!'))
.catch(err => console.log('err:', err))
Above code successfully save image in storage like (DCIM/imageName.jpg)
But i want to change the location of images to be saved somewhere else like (testfolder/1/imagename.jpg) I tried like this:
CameraRoll.saveToCameraRoll({
uri: data.uri,
album: 'test',
}, 'photo').then((newUri) => {
console.log('new location of image => ', newUri);
})
I read this link https://facebook.github.io/react-native/docs/cameraroll.html#savetocameraroll but there is no proper guide or parameter set to change location.
Anyone guide me how can i change path for saving images?
As I said here : How to save a Picture to a specific folder from React Native Camera Roll
On Android, you can use react-native-fetch-blob and its File System Access API (PictureDir constant).
try {
const data = await this.camera.takePictureAsync()
await RNFetchBlob.fs.mkdir(`${RNFetchBlob.fs.dirs.PictureDir}/myfolder`)
await RNFetchBlob.fs.mv(
data.api,
`${RNFetchBlob.fs.dirs.PictureDir}/myfolder/${moment().unix()}.jpg`
)
} catch () {
...
}
https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API