Phonegap的FileTransfer对象是否已过时使用XmlHttpRequest2? [英] Is Phonegap's FileTransfer object obsolete with XmlHttpRequest2?

查看:80
本文介绍了Phonegap的FileTransfer对象是否已过时使用XmlHttpRequest2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有理由继续使用FileTransfer对象,可以通过XmlHttpRequest2发送blob /文件甚至多个文件?

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 ?

使用html5使它成为一个更容易在现代浏览器中运行相同的应用程序并减少代码。或者FileTransfer对象有什么优势吗?

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?

特别是 FormData 似乎也是这样,尽管它只在最新的浏览器上运行。

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

推荐答案

似乎FormData&文件实现是然而,在所有系统上都无法正常工作。因此,使用FileTransfer可能更好。

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

编辑:

我使用XmlHttpRequest在没有FileTransfer的情况下使用它。为了发送,我将一个blob附加到FormData对象,但是我从arraybuffer(file.readAsArraybuffer)构造blob。
对于接收文件,我将responseType设置为'arraybuffer'。
这适用于Chrome和移动版Safari(即Phonegap)。

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).

这篇关于Phonegap的FileTransfer对象是否已过时使用XmlHttpRequest2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆