camera-preview
camera-preview copied to clipboard
How to properly obtain the image file using storeToFile: true
Hello!
I've been trying to save a photo using this plugin.
I'm setting storeToFile: true in the CameraPreviewOption to start the camera beforehand.
const options: CameraPreviewOptions = {
storeToFile: true,
width: window.screen.width,
height: window.screen.height,
parent: "cameraPreview",
position: "rear",
className: "cameraPreview",
enableOpacity: true,
toBack: true,
lockAndroidOrientation: true,
rotateWhenOrientationChanged: false,
}
CameraPreview.start(options);
But then when I try to capture an image, as a result I still get a base64 string.
const cameraPreviewPictureOptions: CameraPreviewPictureOptions = {
quality: 90,
};
const result = await CameraPreview.capture(cameraPreviewPictureOptions);
I wanted to check if this is the correct way to use the storeToFile property, since I need a file instead of a base64 string. Accessing results.value just gives me the entire base64 string.
I'm having the same issue. Did you manage to get the file path?
I'm having the same issue. Did you manage to get the file path?
Not really, I ended up using just the base64 it gives back. I believe that you would have to save that base64 with a different plugin and get the path back from there, or default back to the official camera plugin.