Writing file to desktop using HTML5 FileSystem API

Johan picture Johan · Nov 2, 2013 · Viewed 42.2k times · Source

I'm playing around a bit with the FileSystem API.

I've found a lot of examples where you generate a download link and let the user download the file the "browser way".

I would like to know two things:

  1. Is there any way to write the ajax result in the fiddle as a file directly to the disk (without any type of prompt). Like to the user's desktop for example.

  2. Is blob the most suitable format for this?

http://jsfiddle.net/FBGDe/

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
    if (this.readyState == 4 && this.status == 200){
        console.log(this.response, typeof this.response);
        var img = document.getElementById('img');
        var url = window.URL = window.webkitURL;
        img.src = url.createObjectURL(this.response);
    }
}
xhr.open('GET', 'http://www.newyorker.com/online/blogs/photobooth
                                                       /NASAEarth-01.jpg');
xhr.responseType = 'blob';
xhr.send();      

Answer

Aparajith Sairam picture Aparajith Sairam · Apr 28, 2014

Please note that Filesystem API is no longer part of the standard's specification, as specified at: http://www.w3.org/TR/file-system-api/

EDIT: Quoting the specification in case the link changes: "File API: Directories and System W3C Working Group Note 24 April 2014

Work on this document has been discontinued and it should not be referenced or used as a basis for implementation."

(This does not relate to the question directly, but it is essential to know not to use the FileSystem API further.)

Another link: http://www.html5rocks.com/en/tutorials/file/filesystem/

"In April 2014, it was announced on public-webapps that the Filesystem API spec should be considered dead. Other browsers have showed little interest in implementing it."