Filesaver.js: File save issue in Safari

Created on 12 Feb 2015  路  14Comments  路  Source: eligrey/FileSaver.js

I am using this code

var blob = new Blob([atob(response.payload)], {
    "data":"attachment/csv;charset=utf-8;"
});
saveAs(blob, fname);

Here response.payload is blob data. Its working fine in all browsers but in safari file getting downloaded without name and opening a blank page also. Any help will be highly appreciated.

safari

Most helpful comment

Looks like Safari 10.1 finally supports the Download attrib.

http://caniuse.com/#feat=download
https://webkit.org/status/#feature-download-attribute

All 14 comments

This seems to be a missing feature: https://github.com/eligrey/FileSaver.js#supported-browsers

what is the current recommended way to save things in safari 8? downloadify doesn't seem to work for me, or at least have not found a demo that works in safari. using saveas just silent fails in my test while working in other browsers.

I'm seeing the same problem. Certain file types (e.g. images) open in a new browser tab as blob:... Other file types (e.g. MS Office documents) open a new blank browser tab with no URL at all in the address bar and no file is downloaded. Safari 7.1.5

Duplicate of #12?

Seems to be == #12

So the problem is the time. If the saveAs happens more than 1 second after the click what triggered it, the plugin will overwrite the current window.

having the same problem in Safari. Firefox and Chrom are working! How to prevent this?

If there's no fix yet, how would I make the saveAs open a new tab instead of overwriting the current window?

is there any update on this issue ?

plz?

Any movement on this? I'm seeing some activity on the webkit bugs thread https://bugs.webkit.org/show_bug.cgi?id=102914 as recently as april. Does anyone know the status of this patch and / or if there are any workarounds?

They still have some work to do; see the transitive dependencies of that bug. Lots of recent-ish activity that looks promising though.

the data is wrong, it should be { type: "attachment/csv;charset=utf-8" }

Try setting the mimetype to application/octet-stream to force saving. You will not be able to set the filename, it will default to "unknown" but it's the best you got, another option is to set the mimetype to "text/plain" so it will open it in a new tab so the client can decide where to save and also name it.

var blob = new Blob(['"User","Text"'], {
    "type":"application/octet-stream"
})
saveAs(blob);

FileSaver.js will try to open a new tab window.open but you are only allowed to do so within 1 secound after a user interaction like onclick

if the window.open fails it will replace the current tab but faile to do so if the mimetype can't be renderd by safari

Looks like Safari 10.1 finally supports the Download attrib.

http://caniuse.com/#feat=download
https://webkit.org/status/#feature-download-attribute

Was this page helpful?
0 / 5 - 0 ratings

Related issues

meenucoditas picture meenucoditas  路  6Comments

rhyous picture rhyous  路  6Comments

danielbronder picture danielbronder  路  6Comments

siva3378 picture siva3378  路  7Comments

Toterbiber picture Toterbiber  路  5Comments