gpt4 book ai didi

android - EISDIR : illegal operation on a directory, 在 React Native 文件系统中读取

转载 作者:行者123 更新时间:2023-12-03 19:23:33 30 4
gpt4 key购买 nike

我正在尝试使用以下代码将文件复制到另一个外部文件夹的简单代码:

RNFS.copyFile(sourcePath, destinationPath)
.then(result => {
console.log('file copied:', result);
})
.catch(err => {
console.log('error: ', err.message, err.code);
});

我已经授予 Android.Permission用于在外部目录中读写,但仍然返回此错误:
error:  EISDIR: illegal operation on a directory, read '/storage/emulated/0/' EISDIR

这是依赖项:
"react": "16.9.0",
"react-native": "0.61.2",
"react-native-fs": "^2.15.2"

顺便说一句,我请求正确的许可吗?
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE 
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE

提前感谢您的帮助

最佳答案

我已经解决了这个问题,这是一个愚蠢的错误。我忘了在目标路径 url 中提及文件的名称:

let sourcePath = "/storage/emulated/0/SourceFolder";
let destinationPath = "/storage/emulated/0/DestinationFolder";
let FileName = 'abc.jpg';

destinationPath = destinationPath +"/"+ FileName;

RNFS.copyFile(sourcePath, destinationPath)
.then(result => {
console.log('file copied:', result);
})
.catch(err => {
console.log(err);
});

关于android - EISDIR : illegal operation on a directory, 在 React Native 文件系统中读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58525721/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com