這已經被問了好幾次,但大多數的這些問題沒有答案如何使用PhoneGap的文件傳輸下載圖片,圖片庫中的iOS
我下載象下面這樣的文件,它似乎很好地工作。然而..它並沒有出現在iOS,ehm,gallery上。也就是說,在「照片」應用程序中。
var fileTransfer = new FileTransfer();
var encurl = encodeURI(url);
var filename = url.split('/').slice(-1)[0];
var filepath = "foo/"+filename;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
var syspath = fileSystem.root.toURL() + '/' + filepath;
var fileTransfer = new FileTransfer();
fileTransfer.download(
encurl,
syspath,
function (entry) {
foo.debug("Download success "+syspath);
},
function (error) {
foo.error("Download failed with error "+error.code+' '+syspath);
}
);
}, function (evt) {
foo.error("Filesystem failed with error "+evt.target.error.code);
});
,其結果是
[Log] Download success file:///var/mobile/Applications/68DE0AD9-FBD2-4D82-92C0-2B7634B218D5/Documents//foo/20141030-153810-editor.jpg (console-via-logger.js, line 173)
歡呼。現在,你如何在ios上使用你的手指打開下載?
嘿,你從那以後發現了什麼? – 2015-03-26 10:31:08
是的,請參閱http://stackoverflow.com/questions/21577230/phonegap-save-image-from-url-into-device-photo-gallery - 答案由M165437和我的意見。不要被Canvas2Image困惑(像我一樣)。我現在在ios,android和windows上都有這個產品。 – commonpike 2015-03-26 11:41:39
我不明白的是圖像實際上是在手機上,但沒有出現在畫廊中。這是爲什麼 ?這是一個編碼問題?真的很好。 – 2015-03-26 12:00:06