My app retrieves a list of photos using MediaLibrary.getAssetsAsync(). Later, when I try sharing a single photo using Sharing.shareAsync() it fails with Failed to share the file: Failed to find configured root that contains /storage/emulated/0/DCIM/Camera/IMG_20200410_191652.jpg on Android.
The full photo.uri I’m attempting to share is file:///storage/emulated/0/DCIM/Camera/IMG_20200410_191652.jpg.
I have CAMERA_ROLL and CAMERA permissions granted and have added the following in app.json:
I was able to work past this issue. It seemed to be tripping on the third slash in file:///. I replaced it with file:// and …got a new error that I’ll post in a new thread.
Hi there,
I am having the same problem, after some debugging, I found a workaround this issue.
I am not sure is it the best solution but here is it.
If you got the URI from MediaLibrary it will look like file:///storage/emulated******
So to convert that to a link that Sharing module can understand you should import ImageManipulator module to get the URI for sharing
import * as Sharing from "expo-sharing";
import * as MediaLibrary from 'expo-media-library';
import * as ImageManipulator from "expo-image-manipulator";
import { View, Text, Image, TouchableOpacity, Platform } from "react-native";
openShareDialogAsync = async id => {
try {
let result = await MediaLibrary.getAssetInfoAsync(id);
if (!(await Sharing.isAvailableAsync())) {
alert(`Uh oh, sharing isn't available on your platform`);
return;
}
const manipResult = await ImageManipulator.manipulateAsync(
/// here pass the uri looks like file:////storage/****
result.localUri || result.uri
);
let uriToShear = manipResult.uri
console.log(uriToShear) // It will look like file:///var/mobile/Con
Sharing.shareAsync(uriToShear);
} catch (error) {
console.log(error);
}
};