I think I should have used public-webapps maillist. File API is discussed there. Sorry for spam.<br><br><div class="gmail_quote">On Fri, Jan 8, 2010 at 1:56 PM, Dmitry Titov <span dir="ltr"><<a href="mailto:dimich@google.com">dimich@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<div><br></div><div><div>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'?</div>
<div><br></div></div><div>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.</div>
<div>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.</div>
<div><br></div><div>Now, if the page decides to use XHR to upload the file, I think</div><div><br></div><div>var file = myInputElement.files[0];</div><div>var xhr = ...</div><div>xhr.send(file);</div><div><br></div><div>
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).</div>
<div><br></div><div>Assuming this is desired behavior, what should the following do:</div><div><br></div><div><div>var file = myInputElement.files[0];</div><div>var blob = file.slice(0, file.size);</div><div>// ... now file on the disk changes ...</div>
<div>xhr.send(blob);</div><div><br></div></div><div>Will it:</div><div>- send the new version of the whole file (and update blob.size?)</div><div>- send captured number of bytes from the new version of the file (perhaps truncated since file may be shorter now)</div>
<div>- send original bytes from the previous version of the file that existed when Blob was created (sort of 'copy on write')</div><div>- throw exception</div><div>?</div><div><br></div><div><br></div><div>Thanks,</div>
<div>Dmitry</div>
</blockquote></div><br>