通过浏览器在Android上下载文件时避免内容类型的问题 [英] Avoiding content type issues when downloading a file via browser on Android
问题描述
如果我通过我的web应用程序提供给浏览器中的文件,我通常只设置网址类似 http://website.com/webapp/download/89347/image.jpg
。然后,我设置HTTP头文件内容类型:应用程序/八位字节流;文件名= image.jpg的
和内容处置:附件
If I have a file made available to a browser through my webapp, I normally just set the URL to something like http://website.com/webapp/download/89347/image.jpg
. I then set the HTTP headers Content-Type: application/octet-stream; filename=image.jpg
and Content-Disposition: Attachment
.
不过,在Android。看来我可以下载该文件的唯一方法是设置内容类型:图像/ JPG
。否则,文件名称<未知>
及错误出现
However, on the Android. It seems the only way I can get the file to download is to set Content-Type: image/jpg
. Otherwise the file name says <Unknown>
and an error comes
下载不成功
无法下载。内容不支持该手机上
Download unsuccessful
Cannot download. The content is not supported on this phone
有没有什么办法可以让Android的下载并没有保留的MIME类型的列表中打开通过浏览器的文件?
Is there any way I can get Android to download and open the file through the browser without keeping a list of mime types?
推荐答案
要进行任何下载的预期所有的(尤其是较旧的)的Android版本的工作,你需要...
To make any downloads work on all (and especially older) Android versions as expected, you need to...
- 设置将contentType为应用程序/八位字节流
- 将内容处置的文件名值在双引号
- 写的内容处置文件扩展名大写
阅读我的博客文章的详细信息:
<一href="http://digiblog.de/2011/04/19/android-and-the-download-file-headers/">http://digiblog.de/2011/04/19/android-and-the-download-file-headers/
Read my blog post for more details:
http://digiblog.de/2011/04/19/android-and-the-download-file-headers/
干杯,Jpsy。
这篇关于通过浏览器在Android上下载文件时避免内容类型的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!