Javascript 为什么要对本机RNF';s copyFile()无法访问iOS上的现有文件?

Javascript 为什么要对本机RNF';s copyFile()无法访问iOS上的现有文件?,javascript,ios,swift,react-native,react-native-fs,Javascript,Ios,Swift,React Native,React Native Fs,我正在尝试使用RNFS从“/Documents”文件夹(在ios模拟器上)访问和复制文件,但当.exists()可以找到该文件时,.copyFile()返回错误,因为“文件'temp.jpg'不存在” 为什么会这样 这是我的源文件路径(我也可以使用图像组件访问它): 另外,将“file://”添加到路径也不起作用 /用户/myusername/Library/Developer/CoreSimulator/Devices/D305Z9A4-6C67-4DFE-A07D-1EF4D0302B87/

我正在尝试使用RNFS从“/Documents”文件夹(在ios模拟器上)访问和复制文件,但当.exists()可以找到该文件时,.copyFile()返回错误,因为“文件'temp.jpg'不存在”

为什么会这样

这是我的源文件路径(我也可以使用图像组件访问它):

另外,将“file://”添加到路径也不起作用

/用户/myusername/Library/Developer/CoreSimulator/Devices/D305Z9A4-6C67-4DFE-A07D-1EF4D0302B87/data/Containers/data/Application/B933EF45-391F-4882-986F-92B5430823D0/Documents/temp.jpg

这是我的代码片段,
newlyCroppedImagePath
是上面的路径。exists()返回正确的结果,但.copyFile()返回“不存在”

RNFS.exists(newlyCroppedImagePath)
。然后((成功)=>{
console.log('文件存在!');//{
日志(“存在错误:+err.message”);
});
copyFile(newlyCroppedImagePath、tmpFilePath)
。然后((成功)=>{
log('file moved!');
})
.catch((错误)=>{
console.log(“错误:+err.message);//在

RNFS.exists(newlyCroppedImagePath).then((success) => {
    console.log('File Exists!'); // <--- here RNFS can read the file and returns this
})
此外,请使用RNFS.readDir()检查目录中的可用文件,以检查您的文件是否已显示

提及

RNFS.exists(newlyCroppedImagePath).then((success) => {
    console.log('File Exists!'); // <--- here RNFS can read the file and returns this
})
RNFS.exists(filePath).then((status)=>{
if(status){
    console.log('Yay! File exists')
} else {
    console.log('File not exists')
}
})