这已经被问了好几次,但大多数的这些问题没有答案如何使用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