Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html5 saveAs support in google chrome

I am trying to use saveAs interface as explained here

For the moment, I only worry about Google Chrome, and I uses latest Canary (Version 27.0.1429.0 canary)

Qn1: the article says.

The W3C File API includes a FileSaver interface, which makes saving generated data as easy as saveAs(data, filename), though unfortunately it will eventually be removed from the spec.

Why it would be removed?

Qn2: Below code.

if (window.saveAs) {
    window.saveAs(blob, name);
}else{
    console.log("saveAs not supported")
}

prints

saveAs not supported 

So chrome doesn't support saveAs. That is not the impression I have reading many article online.

like image 325
bsr Avatar asked Mar 04 '13 21:03

bsr


People also ask

How do I watch html5 videos in Chrome?

Try this: Go to http://www.youtube.com/html5 and at the bottom, click "Join the HTML 5 Trail" down at the bottom. (Cookies must be enabled.) You should then be able to watch YouTube videos at the YouTube site, if they don't have ads, etc., etc.

What is Javascript SaveAs?

Description. Use the SaveAs method to save options to the file specified by FileName. The specified file is different from the file for which the FileSection object was created. This means it is not the file you specified in the XML , INI or Binary method of the Storages object.


1 Answers

this is a polyfill, as explained in the article. You have to load the javascript file listed in the article, save it in your resources and link to it in your code: The repository is there: https://github.com/eligrey/FileSaver.js

There are limitations in Chrome, though. If file already saved, the new saving name is incremented : myFile(1), then myFile(2), etc.

I have now a bug on Chrome, which tells can it cannot OPEN the file, but it is just a false warning, as the file is well SAVED, which is the point.

like image 160
Pierre Avatar answered Sep 20 '22 13:09

Pierre