Phonegap 3.0 FileTransfer download not working

点点圈 提交于 2019-12-04 20:19:39

I found the problem in iOS:

The path: path = "file://localhost/var/mobile/Applications/D702F059-A29F-4FF4-A165-D4A903DEDE7D/Documents/captured/2419747919.jpeg"

does not work because it is an URL with "localhost" in it.

From FileEntry in Cordova one can get a string using "fullPath" and "toURL" ... on Android they work both to write a file. On iOS only the fullPath works ... the URL does not successfully write a file!

I had problems with that while working on the iOS Simulator, but once I tested it on the actual device, it worked.

use nativeURL to get the prefix and append your file name to it and pass it to FileTransfer object it will work.

You'll want to use FileEntry.toURL() to get a path that looks like this:

cdvfile://localhost/persistent/path/to/file

See the documentation here: https://github.com/apache/cordova-plugin-file-transfer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!