W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2010

Re: File API: Blob and underlying file changes.

From: Dmitry Titov <dimich@chromium.org>
Date: Fri, 8 Jan 2010 23:03:02 -0800
Message-ID: <28040fc61001082303w35ab3a2cr85071bb299cc5f98@mail.gmail.com>
To: Web Applications Working Group WG <public-webapps@w3.org>
Adding reply from Jonas Sicking from anther list (which I used first by
mistake :( )

Technically, you should send this email to the webapps mailing list,
since that is where this spec is being developed.

That said, this is a really hard problem, and one that is hard to
test. One thing that we decided when we did security review on this
stuff at mozilla is that if a File object is ever passed cross origin
using postMessage, then the File object that the other origin has
should not work if the file is changed on disc. For some definition of
"not work".


On Fri, Jan 8, 2010 at 2:21 PM, Dmitry Titov <dimich@chromium.org> wrote:

> Hi,
>
> Does the Blob, which is obtained as File (so it refers to an actual file on
> disk) track the changes in the underlying file and 'mutates', or does it
> represent the 'snapshot' of the file, or does it become 'invalid'?
>
> Today, if a user selects a file using <input type=file>, and then the file
> on the disk changes before the 'submit' is clicked, the form will submit the
> latest version of the file.
> This may be a surprisingly popular use case, when user submits a file via
> form and wants to do 'last moment' changes in the file, after partial
> pre-populating the form. It works 'intuitively' today.
>
> Now, if the page decides to use XHR to upload the file, I think
>
> var file = myInputElement.files[0];
> var xhr = ...
> xhr.send(file);
>
> should also send the version of the file that exists at the moment of
> xhr.send(file), not when user picked the file (for consistency with form
> action).
>
> Assuming this is desired behavior, what should the following do:
>
> var file = myInputElement.files[0];
> var blob = file.slice(0, file.size);
> // ... now file on the disk changes ...
> xhr.send(blob);
>
> Will it:
> - send the new version of the whole file (and update blob.size?)
> - send captured number of bytes from the new version of the file (perhaps
> truncated since file may be shorter now)
> - send original bytes from the previous version of the file that existed
> when Blob was created (sort of 'copy on write')
> - throw exception
> ?
>
>
> Thanks,
> Dmitry
>
Received on Saturday, 9 January 2010 07:09:58 GMT

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