Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to FileReader in iOS Chrome #612

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

evgeniy-polyakov
Copy link

iOS 13 introduces "download" attribute but it behaves incorrectly in Chrome - the file is always open in same window. This pull request forces to use FileReader in iOS Chrome.

Also merged #578

Dalibor Duba and others added 5 commits July 8, 2019 16:02
@hwhelchel
Copy link

hwhelchel commented Feb 9, 2020

I'm seeing the same issue.

My use case is downloading short videos. On iOS these are quicktime / mov videos. In Safari 13 they download great using saveAs but in Chrome for iOS, Firefox for iOS, FB Messenger's browser it just opens the blob url in the same window and starts playing the video. I may be wrong, but I couldn't find a way to then download the video.

I spiked on testing the FileReader approach in Chrome for iOS. I was able to have it trigger a download in the browser but the file type wasn't present and the file name wasn't present. It was just called "download". Then it would let me navigate to the iPhone file system but the "Save" button was disabled so I was unable to persist the file.

@eligrey if @evgeniy-polyakov is able to fix the merge conflicts here, would you accept this PR? thanks all

@ts-23
Copy link

ts-23 commented Feb 25, 2020

Fantastic work @evgeniy-polyakov, however in ios Chrome, it opens a new tab that defaults to a "document" file name. Is there some way to use a custom filename?

# Conflicts:
#	dist/FileSaver.js
#	dist/FileSaver.min.js
#	dist/FileSaver.min.js.map
#	src/FileSaver.js
@eligrey
Copy link
Owner

eligrey commented Mar 6, 2020

I don't have immediate access to an iOS device. I'll test & merge this sometime next week 👍

@evgeniy-polyakov
Copy link
Author

I don't have immediate access to an iOS device. I'll test & merge this sometime next week 👍

It seems to be already fixed in the original repository for all iOS browsers, not only Chrome. You use 'AppleWebKit' to test User Agent instead of 'CriOS':
https://chromium.googlesource.com/chromium/src.git/+/master/docs/ios/user_agent.md

I'm declining the pull request, no useful fixes here.

evgeniy-polyakov and others added 4 commits March 6, 2020 23:37
This reverts commit 43a6684, reversing
changes made to 493bcf3.
(cherry picked from commit 16a8bb9)
(cherry picked from commit 480d547)
@evgeniy-polyakov
Copy link
Author

evgeniy-polyakov commented Mar 7, 2020

I'm reopening the pull request. AppleWebKit is too wide, it also matches all modern desktop browsers on Win and MacOS platforms: https://deviceatlas.com/blog/list-of-user-agent-strings
So in the current version almost all desktop browsers fall back to FileReader that is inappropriate I guess. @eligrey please consider to merge this pull request or suggest another UA pattern that covers newest iOS devices.

@carlosperate
Copy link

I believe this issue is still present in iOS 14 with Chrome v87.
As it is, it works in Safari where the file downloads with the right filename, but in Chrome it opens the text content in the same tab.
Using this PR in chrome it downloads a file without filename or extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants