Javascript Expo FileSystem.moveAsync位置不可移动?
我正在使用expo API开发react原生应用程序,该应用程序基本上先拍摄一张照片,然后应用程序使用ImageEditor.cropImage进行裁剪,最后将图片从缓存复制到另一个位置。守则:Javascript Expo FileSystem.moveAsync位置不可移动?,javascript,react-native,exp,Javascript,React Native,Exp,我正在使用expo API开发react原生应用程序,该应用程序基本上先拍摄一张照片,然后应用程序使用ImageEditor.cropImage进行裁剪,最后将图片从缓存复制到另一个位置。守则: takePicture = async function() { if (this.camera) { this.camera.takePictureAsync().then(async (data) => { cropdata = {
takePicture = async function() {
if (this.camera) {
this.camera.takePictureAsync().then(async (data) => {
cropdata = {
offset:{x:0, y:0},
size:{width:100, height:100},
};
await ImageEditor.cropImage(
data.uri,
cropdata,
async (uri) => {
FileSystem.moveAsync({
from: uri,
to: `${FileSystem.documentDirectory}photos/Photo_${this.state.photoId}.jpg`,
}).then(() => {
this.setState({
photoId: this.state.photoId + 1,
});
Vibration.vibrate();
});
},
(error) => {
console.log(error);
}
);
});
}
};
但显示了以下错误:
[未处理的承诺拒绝:错误:位置]
'file:///data/user/0/host.exp.exponent/cache/ReactNative_cropped_image_574763720.jpg'
不可移动。]
有什么想法吗 Expo的文件系统模块可以复制/移动/等以前保存在应用程序范围内的文件(例如通过ImagePicker或使用Asset.loadAsync)。ImagerEditor是React的核心本机功能,它将图像保存到Expo范围之外的文件中,因此文件系统无法对该文件执行操作。有关这方面的更多信息,请参见: 因此,与其使用
ImageEditor.cropImage()
,不如使用expo