W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: [XHR2] Blobs, names and FormData

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 11 Jul 2011 12:05:31 -0700
Message-ID: <CA+c2ei_jeofC3Qy6X=AL-kCWNY+yLO0r528hym08zEzeQVsbSg@mail.gmail.com>
To: Adrian Bateman <adrianba@microsoft.com>
Cc: Anne van Kesteren <annevk@opera.com>, Julian Reschke <julian.reschke@gmx.de>, Alfonso Martínez de Lizarrondo <amla70@gmail.com>, Webapps WG <public-webapps@w3.org>
2011/7/11 Adrian Bateman <adrianba@microsoft.com>:
> On 11 July 2011 10:53, Jonas Sicking wrote:
> On Mon, Jul 11, 2011 at 10:12 AM, Adrian Bateman <adrianba@microsoft.com> wrote:
>> > Some content management systems use the original filename by default
>> > when storing files in document libraries. It's certainly a lesser use case
>> > but seems like a relatively trivial change to the API. I don't see it as
>> > sugar, since it's not possible to achieve this on the client in any other way.
>> I've proposed adding the following function to BlobBuilder:
>> interface BlobBuilder {
>>   ...
>>   File getFile(in DOMString name, [optional] in DOMString contentType)
>>   ...
>> };
>> This will let you accomplish the same thing in just 2 additional lines
>> of javascript (one of which can be reused).
> Well, yes, there are multiple ways of proposing a solution. My point was there is no easy way to do this without adding some functionality somewhere (I don't consider manually constructing a multi-part message a simple approach). I don't like the BlobBuilder solution because it adds the notion of needing to link the same underlying blob data to both a Blob and File, which suggests an extra level of abstraction in the implementation. I'm not sure what other use case there is for getFile and I prefer the more isolated simpler fix to FormData.

You already need the ability to let blobs and files share data. The
simplest situation is calling file.slice() which will create a Blob of
the same size and contents as the file. But the same thing can also
happen using BlobBuilder by adding a single File to it and then
calling getBlob.

But this does indeed only create Blobs that share the contents of a
File, and not the other way around.

In gecko we implement Blobs and Files using the exact same class.
Internally it just keeps a boolean flag indicating which of the two
public interfaces it exposes. So far I have not yet seen a downside
with this implementation strategy.

Charles Pritchard mentioned a good use case in his last email.

/ Jonas
Received on Monday, 11 July 2011 19:06:35 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:22 UTC