I’m having a problem using @react-native-community/cameraroll
.
Here’s my code:
const handleSaveImageToDevice = async () => {
try {
const uri = await captureRef(viewRef, {
format: 'jpg',
quality: 0.8,
});
const image = CameraRoll.save(uri, {
type: 'photo',
album: 'Generated Image',
});
} catch (e) {
return e;
}
};
As seen in the code I used captureRef
to save react elements with ref
as image.
The behavior is working as expected. If the user clicks the save button the image will be saved to the designated folder. But the problem is it saves random file name. I want to rename it like for example "generated_image".
2
Answers
I forgot to update this but I already found a way to fix my problem using third party library
react-native-fs
When you are capturing there is option for image file name:
Refer below link:
https://github.com/gre/react-native-view-shot/issues/116#issuecomment-1155523609