RE: [XHR2] Blobs, names and FormData

Just catching up with this thread. We ran into the same problem last week while
investigating FormData and XHR. Since FormData is designed to allow XHR to interact
with existing form end-points that usually required a navigation, we've found that
few of them have been tested with empty filenames.

On Wednesday, June 29, 2011 9:35 AM, Alfonso Martínez de Lizarrondo wrote:
> All I want is a way for the web page to state that when a Blob is used in
> a FormData object it should be send to the server with a proposed filename.
> No sniffing. No guessing. It's up to the script to suggest a correct
> filename (if it wants), or use whatever is the default filename used by the
> browser (Blob23g22g3024j23g209gj3g and the like, extensionless)
>
> My first simple approach was:
> formdata.append("elementName", blob, "picture.png");
>
> Jonas has suggested instead
> blobbuilder.getFile("picture.png")
>
> I don't mind one way or another, or something else you think it's better.

I was about to send a similar proposal. We'd prefer to add an optional argument
to append that specifies the filename. This is the smallest change to
implementations and doesn't require developers to understand the BlobBuilder in
order to use FormData. Having to create another reference to a Blob and probably
deal with managing a File and Blob both pointing to the same data seems
unnecessarily involved when all we want is to get the filename into the FormData
object.


On Thursday, June 30, 2011 12:28 AM, Julian Reschke wrote:
> On 2011-06-29 18:34, Alfonso Martínez de Lizarrondo wrote:
> > ...
> > No.
> >
> > All I want is a way for the web page to state that when a Blob is used
> > in a FormData object it should be send to the server with a proposed
> > filename. No sniffing. No guessing. It's up to the script to suggest a
> > correct filename (if it wants), or use whatever is the default
> > filename used by the browser (Blob23g22g3024j23g209gj3g and the like,
> > extensionless) ...
> 
> In which case there should also be a way to send the actual media type,
> no?

Yes, the blob has a content type so the correct type can also be sent.

Received on Thursday, 7 July 2011 01:01:42 UTC