react-native - 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`,
});
解决方案
Expo的文件系统模块可以复制/移动/等。以前保存在应用范围内的文件(例如通过 ImagePicker 或使用 Asset.loadAsync)。ImagerEditor 是 React Native 的核心功能,它将您的图像保存到 Expo 范围之外的文件中,因此 FileSystem 无法对该文件执行操作。现在是不是有点清楚了?
更多信息:https ://forums.expo.io/t/where-does-camera-takepictureasync-save-photos/6475/7
推荐阅读
- sparql - 从本体中选择与给定实例有关系的所有实例
- django - 仅在创建时排除 Django 模型的字段
- android - 在 micropython 服务器上未收到 OkHttp 发送的 Http 请求
- python - 图像分割以在生物图像中找到细胞
- python - 已安装的 conda 包无法导入
- ruby - 创建一个要求输入密码而不在代码中显示的程序
- javascript - 一个基本的 Javascript Todo 应用程序在 ForLoop 中表现得很奇怪
- vue.js - Vue.js / Vuetify:如何在我的对话框中删除这个巨大的空白?
- javascript - JavaScript 不等待承诺解决。使用 Async /Await 扫描 AWS DynamoDB 时
- keras - y 的 Keras 规范