FileSaver.js icon indicating copy to clipboard operation
FileSaver.js copied to clipboard

blob opens in current tab iOS Safari

Open shikinen opened this issue 5 years ago • 14 comments

I have a problem with saveAs function in iOS Safari -> blob is opened in the current tab and I want it to open in a new tab at least, I am aware that it won't trigger downloading the file but I just need to open the file in NEW tab.

I rummaged through issues and I came across conflicting information in this matter -> some say it opens in new tab, some do not and I am confused.

Does anyone have it implemented in a way that blob opens in a new tab, not the current one?

shikinen avatar Jul 22 '19 08:07 shikinen

I have this problem too. :(

omidpaydar avatar Aug 06 '19 06:08 omidpaydar

+1 Documentation says it will open in a new tab, but it doesnt... iOS 12.4, Safari

enterframe avatar Aug 27 '19 13:08 enterframe

+1 same for me , iOS 12.4 someone can help to fix or workaround ?

hacaro76 avatar Sep 04 '19 06:09 hacaro76

Same here, not working on iOS 12.4.*

phuocnelet avatar Oct 16 '19 19:10 phuocnelet

Strangely, if you put the button inside an iframe, it will work properly and iOS will pop up the "Do you want to Download ...pdf", allowing you to download it to your downloads folder. See example here:

https://codepen.io/ianaya89/pen/JoRNyK

(If you take this code out of the iframe, it fails. Add your own iframe instead of using the codepen one, and it works again).

I'm not sure it's a good idea to rely on this behaviour.

groupboard avatar Jan 07 '20 01:01 groupboard

I have this problem and i register a pull request fot it... https://github.com/eligrey/FileSaver.js/pull/673 please merge that if its correct to solve problem.

ehsanzarei2 avatar Aug 26 '20 05:08 ehsanzarei2

Is this fix in master ? I just import v2.05 and on safari pdf open same window not download.

felek000 avatar Jan 15 '21 07:01 felek000

@ehsanzarei2 i don't see any difference in behavior on your branch.

heyalexchoi avatar Feb 15 '21 04:02 heyalexchoi

This project seems to be dead. Many problems not solved... :/

usb248 avatar Oct 03 '21 21:10 usb248

I found that you just need to add MIME Content Type of blob file become: application/octet-stream, it will download directly.

nhandt-nals avatar Oct 27 '21 09:10 nhandt-nals

+1

DEVfancybear avatar Nov 15 '21 03:11 DEVfancybear

I have the same issue in Firefox 100.0.2 - When downloading a file using saveAs(xhr.response, fileName, saveAsOpts);

The current tab is replaced by the download. It works fine in Chromium.

My server returns the following headers:

content-disposition: attachment; filename=myFile.pdf
content-type: application/pdf

maciej-zabielski avatar May 26 '22 14:05 maciej-zabielski

The firefox bug is already fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=1766420

groupboard avatar May 26 '22 14:05 groupboard

The firefox bug is already fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=1766420

thanks for a good find - when type is changed to application/octet-stream as mentioned earlier it does open in a new tab correctly in Firefox as well.

maciej-zabielski avatar May 27 '22 10:05 maciej-zabielski