2014-11-17 2 views
0

Cordova File Plugin을 사용하여 파일의 이름을 바꾸려고합니다. 아무런 설명도없이 Code 1000에 오류가 있습니다. 여기에 내가 이미 Download 폴더에 abc.pdf에 놓여있다코르도바 파일 이름 바꾸기 - 오류 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); 
} 

을 사용하고 코드 샘플입니다. 내가 뭘 잘못하고 있는지 잘 모르겠다. 나는 안드로이드 (플랫폼 버전 3.4.0)

+1

아마도 원래 파일 항목을 가져 오기 위해 새로운 FileEntry 대신 resolveLocalFileSystemURI를 사용하려고합니까? – QuickFix

답변

1

그것은 작동하지만 다음과 같은 방법으로를 코르도바 4.0.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);