在iOS上从HTTP强制下载文件 [英] Force file download from HTTP on iOS

查看:231
本文介绍了在iOS上从HTTP强制下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击链接后,我正在使用一个链接来自动下载文件. 此下载在Android和Windows上都可以正常运行.

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

但是在MAC和iOS上,该文件仅在浏览器中打开.它没有下载.

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"

我检查了SO,并建议使用

I checked on SO and some suggested to use

Content-Type: application/force-download

但这是Hack,不是注释的标准.那么如何在iOS和MAC中实现下载?

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

推荐答案

iOS Safari从v13.1开始支持该功能.参见此处: https://caniuse.com/#feat=download

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

在内容类型标题中,您可以

In your content-type header you can

这篇关于在iOS上从HTTP强制下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆