Re: [XHR2] Blobs, names and FormData

On Fri, Jun 17, 2011 at 9:24 AM, Jonas Sicking <jonas@sicking.cc> wrote:
> On Friday, June 17, 2011, Anne van Kesteren <annevk@opera.com> wrote:
>> On Wed, 20 Apr 2011 23:52:21 +0200, Jonas Sicking <jonas@sicking.cc> wrote:
>>
>> When a Blob is appended to a FormData, the XHR2 spec currently says
>> that the filename used should be the empty string unless the Blob is
>> also a File. If such a FormData is later submitted using
>> XMLHttpRequest, this will result in a request that contains something
>> similar to:
>>
>> Content-Disposition: form-data; name="myblob"; filename=""
>>
>> Unfortunately there appears to be some servers that are unable to deal
>> with the filename parameter being empty. See details and examples in
>> [1]. Chrome apparently already disregards the specification here and
>> generates a seemingly random value for the filename parameter.
>>
>> Unless someone comes up with a reason otherwise, I suspect we need to
>> change the spec here.
>>
>> [1] https://bugzilla.mozilla.org/show_bug.cgi?id=649150
>>
>>
>> Just set it to "blob" maybe? Or "blob.bin" or some such?
>
> That works for me. I'm curious to know why webkit went with a more
> complex name though.

I've written a patch to make Firefox use "blob" as name. This is used
both when the FormData contains a Blob, and when it contains a File
with an empty name.

In firefox you can currently get a file with an empty name using an
experimental canvas.mozGetAsFile(name, type, ...) API, though this
will eventually be changed to canvas.toBlob as has now been specified.
But I suspect we'll end up with other APIs eventually which can end up
producing files with empty names (I kind'a think that BlobBuilder
should have a getFile(name) function for example).

/ Jonas

Received on Wednesday, 29 June 2011 03:01:51 UTC