logError: function(error) { console.log(error); } downloadFile: function(format, file_name, data){ if(!format){ format = 'txt'; } if(!file_name){ file_name = 'default'; } file_name = file_name + '.' + format; if(data.length == 0){ return; // stupid stub } window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem; window.requestFileSystem(window.TEMPORARY, 1024*1024, function(fs) { fs.root.getFile(file_name, {create: true}, function(fileEntry) { fileEntry.createWriter(function(fileWriter) { var blob = new Blob([data]); fileWriter.addEventListener("writeend", function() { chrome.tabs.create({ url: fileEntry.toURL() }); }, false); fileWriter.write(blob); }, logError); }, logError); }, logError); },
Monday, November 17, 2014
Chrome extension download file example
Subscribe to:
Posts (Atom)