I am building an app that let's the user take a picture or select an image from the camera roll. I want to store a link to that image with @react-native-async-storage/async-storage. When I use react-native-image-picker to select an image or take a photo I get a response like this:
{"fileName": "ECB1469E-6518-43E5-AEEE-7EEAFA38F945.jpg", "fileSize": 9181, "height": 300, "type": "image/jpg", "uri": "file:///var/mobile/Containers/Data/Application/A2B000FA-2393-4D34-9DBC-DE835E3BB3C4/tmp/ECB1469E-6518-43E5-AEEE-7EEAFA38F945.jpg", "width": 400}
And in the documentation it says:
Note on file storage
Image/video captured via camera will be stored in temporary folder so will be deleted any time, so don't expect it to persist. Use saveToPhotos: true (default is false) to save the file in the public photos.
So I assume I cannot just save the uri from the response. Now I wonder how I would get a link to that image in the public photos that I can save and that stays valid even if the temporary folder gets cleared or do I need to copy the file to my apps Document folder?
This is the code I use to let the user take a photo
const options = {
mediaType: 'photo',
saveToPhotos: true,
maxHeight: 300,
maxWidth: 450,
quality: 0.3,
};
const takePhoto = () => {
const cb = (request) => {
console.log(request);
if (!request.errorCode && !request.didCancel) {
// save the image link here
}
};
launchCamera(options, cb);
};```