Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I added a call to <code>window.webkitStorageInfo.requestQuota</code>, and now it works. I can't get why it is necessary, as I started Chrome with the <code>--unlimited-quota-for-files</code> option.</p> <p>Here the working code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script&gt; window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; function onError(e) { console.log('Error', e); } var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://upload.wikimedia.org/wikipedia/fr/2/26/10_francs_Mathieu_1987_F365-28_revers.jpg', true); xhr.responseType = 'blob'; xhr.onload = function(e) { window.webkitStorageInfo.requestQuota(PERSISTENT, 1024*1024, function(grantedBytes) { window.requestFileSystem(PERSISTENT, 1024 * 1024, function(fs) { fs.root.getFile('image.jpg', {create: true}, function(fileEntry) { fileEntry.createWriter(function(writer) { writer.onwrite = function(e) {}; writer.onerror = function(e) {}; var blob = new Blob([xhr.response], {type: 'image/jpeg'}); writer.write(blob); }, function(e) { console.log('Error', e); }); }, function(e) { console.log('Error', e); }); }, function(e) { console.log('Error', e); }); }, function(e) { console.log('Error', e); }); window.requestFileSystem(PERSISTENT, 1024 * 1024, function(fs) { fs.root.getFile('image.jpg', {create: false}, function(fileEntry) { fileEntry.file(function(file) { var reader = new FileReader(); reader.onloadend = function(event) { var img = document.createElement("img"); img.src = event.target.result; document.body.parentNode.insertBefore(img, document.body.nextSibling); }; reader.readAsDataURL(file); }, function(e) { console.log('Error', e); }); }, function(e) { console.log('Error', e); }); }, function(e) { console.log('Error', e); }); }; xhr.send(); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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