我有一个可以拍照的工作应用程序,但我想将图片从缓存文件夹复制或移动到另一个文件夹。我无法正常工作,它返回错误 [object Object]。
问候
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);
}
}
最佳答案
经过几个小时的工作,我做到了:
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);
}
关于image - Cordova android 无法从缓存目录复制图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29415022/