Trying to share a camera image using Sharing.shareAsync. Believe I have a proper URI but it’s throwing the error Not allowed to read file under given URL.
URI is file://storage/emulated/0/DCIM/934a455e-832d-4591-98b7-5c4bd821edfa.jpg
App has CAMERA & CAMERA_ROLL permissions and my app.json includes the following:
It looks like this may be a bug in the `Sharing` API. You can work around it for now by copying the file to your document directory and then sharing from there. Here's an example: https://snack.expo.io/@notbrent/share-media-library-photo
Relevant code from that example below:
// Placeholder for getting asset from MediaLibrary
let results = await MediaLibrary.getAssetsAsync({ first: 1 });
let asset = results.assets[0];
// Use FileSystem to copy the image from its original location to the app document directory
let assetUriParts = asset.uri.split("/");
let assetName = assetUriParts[assetUriParts.length - 1];
let uri = `${FileSystem.documentDirectory}/${assetName}`;
await FileSystem.copyAsync({
from: asset.uri,
to: uri,
});
// Share the image from the uri that you copied it to
Sharing.shareAsync(uri);