Gags
Gags

Reputation: 3829

Force file download from HTTP on iOS

I am using a link to auto download file once clicked. This download is working all fine in Android and Windows.

But on MAC and iOS the file is opening in browser only. It is not downloading.

I'm setting below response headers:

Content-Type: application/octet-stream
Content-Disposition: attachment; filename="filename.csv"

I checked on SO and some suggested to use

Content-Type: application/force-download

But it is Hack, not a standard as per comments. So how can I achieve download in iOS and MAC?

Upvotes: 1

Views: 4719

Answers (1)

Shaunak Sontakke
Shaunak Sontakke

Reputation: 1270

It's supported in iOS Safari from v13.1 onwards. See here: https://caniuse.com/#feat=download

In your content-type header you can hack it to work by setting the content type header in your server response

Content-Type: application/force-download

Upvotes: 2

Related Questions