W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2010

Re: FormData and BlobBuilder - duplication of functionality?

From: Michael Nordman <michaeln@google.com>
Date: Tue, 13 Apr 2010 17:34:24 -0700
Message-ID: <x2mfa2eab051004131734la93e0d6bj4062b02d099684d5@mail.gmail.com>
To: Dmitry Titov <dimich@google.com>
Cc: Web Applications Working Group WG <public-webapps@w3.org>
FormData produces multipart encoded data (with boundaries and such) whereas
BlobBuilder simply concatenates data together. Those are different
functions. Having different ctors for these object types
seems appropriate to me. There's also been talk of either initializing a
<form> with FormData and/or extracting FormData from a <form>. If things
like that come to be, a different object type helps with clarity (at least
to me).

Hmmm... maybe FormData could have a toBlob() method, and an inverse means of
initializing a FormData object with a properly encoded Blob.

On Tue, Apr 13, 2010 at 5:11 PM, Dmitry Titov <dimich@google.com> wrote:

> Hi,
>
> It seems we are currently implementing 2 very similar objects - FormData<http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-formdata-interface>
>  and BlobBuilder<http://www.w3.org/TR/file-writer-api/#idl-def-BlobBuilder>.
> Both can be created, then strings or Blobs can be appended, then it can be
> sent via XHR or saved into a file (well, FormData can not be saved in the
> file yet). But, they are very similar:
>
> var bb = new BlobBuilder();
> bb.appendText("Lorem ipsum");
> bb.appendBlob(someBlob);
> xhr.send(bb.getBlob());
>
> var fd = new FormData();
> fd.appendText("data1", "Lorem ipsum");
> fd.appendBlob("data2", someBlob);
> xhr.send(fd);
>
> Are those two similar enough to justify merging them into a single object
> (defined as a a list of named BlobItems) that could be used for both?
>
> One difference is that BlobBuilder does not use a mime wrapper around data
> pieces, but rather concatenates them - there could be a property for that.
>
> Dmitry
>
Received on Wednesday, 14 April 2010 00:35:07 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:38 GMT