[whatwg] File API - does Blob 'track' the changes in the underlying file on the disk?

Jonas Sicking jonas at sicking.cc
Fri Jan 8 14:22:45 PST 2010


On Fri, Jan 8, 2010 at 1:56 PM, Dmitry Titov <dimich at google.com> 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
> ?

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".

/ Jonas



More information about the whatwg mailing list