Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p><strong>Update</strong></p> <p>BlobBuilder has been <a href="https://developer.mozilla.org/en-US/docs/Web/API/BlobBuilder" rel="nofollow noreferrer">obsoleted</a> see how you go using it, if you're using it for testing purposes.</p> <p>Otherwise apply the below with migration strategies of going to <em>Blob</em>, such as the answers to <a href="https://stackoverflow.com/questions/15030906/how-to-replace-the-deprecated-blobbuilder-with-the-new-blob-constructor">this question</a>.</p> </blockquote> <h3>Use a Blob instead</h3> <p>As an alternative there is a <a href="https://developer.mozilla.org/en/DOM/Blob" rel="nofollow noreferrer">Blob</a> that you can use in place of <a href="https://developer.mozilla.org/en/DOM/File" rel="nofollow noreferrer">File</a> as it is what File interface derives from as per <a href="http://www.w3.org/TR/FileAPI/#file" rel="nofollow noreferrer">W3C spec</a>:</p> <pre><code>interface File : Blob { readonly attribute DOMString name; readonly attribute Date lastModifiedDate; }; </code></pre> <blockquote> <p>The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.</p> </blockquote> <h3>Create the Blob</h3> <p>Using the <a href="https://developer.mozilla.org/en/DOM/BlobBuilder" rel="nofollow noreferrer">BlobBuilder</a> like this on an existing JavaScript method that takes a File to upload via <code>XMLHttpRequest</code> and supplying a Blob to it works fine like this:</p> <pre><code>var BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder; var bb = new BlobBuilder(); var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://jsfiddle.net/img/logo.png', true); xhr.responseType = 'arraybuffer'; bb.append(this.response); // Note: not xhr.responseText //at this point you have the equivalent of: new File() var blob = bb.getBlob('image/png'); /* more setup code */ xhr.send(blob); </code></pre> <h3>Extended example</h3> <p>The rest of the sample is up on <a href="http://jsfiddle.net/NickJosevski/VTSUs/" rel="nofollow noreferrer">jsFiddle</a> in a more complete fashion but will not successfully upload as I can't expose the upload logic in a long term fashion.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload