On 08/15/2013 09:20 AM, Roger Dentz wrote:
> I'm developing a B2G app that sends multipart/related data to a server. The data is an XML header (part 1) followed by a binary file wrapped in XML (part 2). The file can be large and needs to be sent using http chunking. I don't see how to do http chunking with XMLHttpRequest, and TcpSocket won't let you use port 80 for non-certified apps (app will be privileged, just not certified). Are there any other options?
There is currently no way to produce data on demand for XHR from
content-space. (Chrome code in Firefox is capable of doing it,
however.) The good news is that XHR lets you send a Blob, and you can
build a Blob out of multiple parts, including other Blobs that are
disk-backed. See
https://developer.mozilla.org/en-US/docs/Web/API/Blob#Constructor
Presumably your data is already coming from disk, so this should work out.
For example:
var myAggregateBlob = new Blob([multipartRelatedStuffAndXML, myFileBlob,
multipartRelatedPartEnd])
Andrew