【发布时间】:2021-06-06 02:58:54
【问题描述】:
我正在开发一个 react native 项目。我需要将捕获的图像存储在自定义文件夹中。
我为此使用 react native fs 库。我可以在所需目录中创建图像,但无法在我的 iphone 文件目录中看到这些图像。
这是我用来存储图像的代码。
async moveAttachment(capturedImagePath) {
$filePathDir = `${RNFS.DocumentDirectoryPath}/myapp/myfilename`;
$filePath = `${$filePathDir }/myfilename.png`;
return new Promise((resolve, reject) => {
RNFS.mkdir(filePathDir)
.then(() => {
RNFS.moveFile(capturedImagePath, filePath )
.then(() => resolve(dirPictures))
.catch(error => reject(error));
})
.catch(err => reject(err));
});
}
我可以在模拟器的文档目录中看到图像,但在 iPhone > 文件目录中看不到。
请帮我解决这个问题。
【问题讨论】:
-
该文件将存储在应用程序的文档目录中。你怎么检查它不存在?因为如果您正在查看
Files应用程序,您不会在那里看到它。 -
@Andrew 我需要将文件存储在本地存储中,这样我就可以在不使用我的应用程序的情况下访问它们。
标签: react-native react-native-fs