2015-04-02 65 views
3

我有一個工作的應用程序,需要圖片,但我想複製或移動圖片從緩存文件夾到另一個文件夾。我不能做到這一點,它會返回我錯誤[對象對象]。科爾多瓦android無法從緩存目錄複製圖像

問候

function copiePhoto() { 
try { 
    var fail = function (err) { 
     alert(err); 
    }; 
    window.resolveLocalFileSystemURI("file:///storage/emulated/0/Android/data/com.coolappz.capigo/cache/1427968060754.jpg", function (file) { 
     window.resolveLocalFileSystemURI("file:///test", function (destination) { 
      file.moveTo(destination, "test.jpg"); 
     }, fail); 
    }, fail); 
} catch (err) { 
    alert("copie : " + err); 
} 

}

回答

5

我做了一些工作小時後作品:

function recupImage(imageURI) { 
    window.resolveLocalFileSystemURI(imageURI, copiePhoto, fail);  
} 

function copiePhoto(fileEntry) { 
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) { 
     fileSys.root.getDirectory("photos2", {create: true, exclusive: false}, function(dir) { 
       fileEntry.copyTo(dir, fileEntry.name, onCopySuccess, fail); 
      }, fail); 
    }, fail); 
} 

function onCopySuccess(entry) { 
    alert('image copié dans le chemin : ' + entry.fullPath); 
} 

function fail(error) { 
    alert(error.code); 
}