首页 > 解决方案 > React native:Error:Location ..... 不可移动

问题描述

我已经录制了一些音频文件,然后我试图将这些音频文件移动到文件夹的默认路径。因为出现错误,例如 Error: Location '''file:///data/data/host.exp.exponent/cache /ExperienceData/%40Fanonymous%2FCameraApplication/filename.3gp''' 不可移动。如果有人遇到同样的问题,请告诉我。但我的默认路径是:file:///data/data/host.exp.exponent/cache/ExperienceData/%2540anonymous%252FCCameraApplication/filename.3gp

这里附上我的示例代码。

const info = await FileSystem.getInfoAsync(this.recording.getURI());
    console.log(`FILE INFO: ${JSON.stringify(info)}`);
    const currentTime=Date.now();
    await FileSystem.moveAsync({
      from: `${JSON.stringify(info.uri)}`,
      to: `${FileSystem.documentDirectory}audios/${currentTime}.3gp`,
    });

标签: react-nativefilesystemsexpo

解决方案


Expo的文件系统模块可以复制/移动/等。以前保存在应用范围内的文件(例如通过 ImagePicker 或使用 Asset.loadAsync)。ImagerEditor 是 React Native 的核心功能,它将您的图像保存到 Expo 范围之外的文件中,因此 FileSystem 无法对该文件执行操作。现在是不是有点清楚了?

更多信息:https ://forums.expo.io/t/where-does-camera-takepictureasync-save-photos/6475/7


推荐阅读