2014-10-30 34 views
2

这已经被问了好几次,但大多数的这些问题没有答案如何使用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上使用你的手指打开下载?

+0

嘿,你从那以后发现了什么? – 2015-03-26 10:31:08

+0

是的,请参阅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

+0

我不明白的是图像实际上是在手机上,但没有出现在画廊中。这是为什么 ?这是一个编码问题?真的很好。 – 2015-03-26 12:00:06

回答

-1

我会记住这为Phonegap - Save image from url into device photo gallery

我很高兴与M165437和我的意见的答案重复。这回答了我的问题。

+0

好吧,有趣:-)我问一个问题,9个月没有答案,决定标记自己的答案为一个重复的,我不能,所以我添加一个有用的指针,并接受我自己,然后我得到downvotes为: - D – commonpike 2017-09-12 13:24:03