Android Cordova文件重命名-错误1000
我正在尝试使用Cordova文件插件重命名文件。它给出了Android Cordova文件重命名-错误1000,android,file,cordova,cordova-plugins,Android,File,Cordova,Cordova Plugins,我正在尝试使用Cordova文件插件重命名文件。它给出了code 1000错误,没有任何描述。这是我正在使用的代码示例 window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); function gotFS(fileSystem) { console.log('root url '+fileSystem.root.toURL()); var entry = new FileEntry("Downl
code 1000
错误,没有任何描述。这是我正在使用的代码示例
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
function gotFS(fileSystem) {
console.log('root url '+fileSystem.root.toURL());
var entry = new FileEntry("Download/abc.pdf");
fileSystem.root.getDirectory("Download", {create: true, exclusive: false},
function (directory) {
entry.moveTo(directory, "file.pdf", success, fail);
}, fail);
}
function success(fileEntry) {
console.log("New Path: " + fileEntry.fullPath);
}
function fail(error) {
console.log("Error: " + error);
}
我已经把abc.pdf
放在Download
文件夹中。
不知道我做错了什么
我正在使用Cordova 4.0.0和Android(平台版本3.4.0)它工作正常,但采用以下方式
fileSystem.root.getFile("Download/abc.pdf", {}, function(file){
fileSystem.root.getDirectory("Download", {}, function (directory) {
file.moveTo(directory, "file.pdf", success, fail);
}, function(error){
console.log(error,"Directory Error ");
});
}, function(error){
console.log(error,"File Error ");
});
我有一个肮脏的(?)工作版本的相同
var entry = new FileEntry("abc.pdf");
entry.fullPath = "//Download/abc.pdf";
entry.nativeURL = fileSystem.root.toURL() + "Download/abc.pdf";
entry.filesystem = new FileSystem('persistent');
var dirEntry = new DirectoryEntry("Download");
dirEntry.fullPath = "//Download/";
dirEntry.nativeURL = fileSystem.root.toURL() + "Download/";
dirEntry.filesystem = new FileSystem('persistent');
entry.moveTo(dirEntry, "file.pdf", success, fail);
可能尝试使用resolveLocalFileSystemURI而不是新的FileEntry来获取原始文件条目?