Is Phonegap's FileTransfer object obsolete with XmlHttpRequest2?

佐手、 提交于 2019-12-10 22:44:23

问题


Is there a reason to still use the FileTransfer object with the availabilty of sending blobs/files or even multiple files in forms via XmlHttpRequest2 ?

Using html5 makes it a lot easier to run the same app in a modern browser as well and reduces code. Or are there any advantages to the FileTransfer object?

Especially FormData seems to do the same, though it runs only on the latest browsers.


回答1:


It seems the FormData & file implementation is not working properly on all systems, yet. Therefore it's probably better to use FileTransfer.

EDIT:

I got it working without FileTransfer using XmlHttpRequest. For sending I append a blob to a FormData object, however I construct the blob from an arraybuffer (file.readAsArraybuffer). For receiving files I set the responseType to 'arraybuffer'. This works on Chrome and mobile Safari (i.e. Phonegap).



来源:https://stackoverflow.com/questions/17480725/is-phonegaps-filetransfer-object-obsolete-with-xmlhttprequest2

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