Android的HTTP头附件的文件名被忽略 [英] Android HTTP header attachment filename ignored

查看:260
本文介绍了Android的HTTP头附件的文件名被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我保持一个店,它允许人们下载他们购买的MP3。他们进入下载MP3的URL的形式是:

I maintain a store which allows people to download mp3s they have purchased. The URL they enter to download the mp3 is of the form:

http://domainName/download.php?a=123&b=456

下面是我的PHP程序发送到浏览器(使用Fiddler捕获)一个典型的头:

Here is a typical header which my php program sends to the browser (captured with Fiddler):

Cache-Control: must-revalidate, post-check=0, pre-check=0
Content-Type: audio/mpeg
Content-Length: 3011430
Content-Disposition: attachment;filename="AIR FOR PIPES.MP3";

在Android平板电脑(ASUS变压器),无论是pre 4.0或4.0发布,下载的文件被称为的download.php,而不是空气PIPES.MP3。换句话说,浏览器将忽略该附件文件名。至少乐曲的播放罚款,甚至要以.php为后缀!奇怪的是三星的Andr​​oid充电2.3.6手机上的文件名是AIR_FOR_PIPES.MP3(手机添加这是很好的下划线)。在Windows上,code适用于IE,火狐,Chrome和Safari的罚款。只有平板电脑是给我的悲伤与文件名。

On an Android tablet (ASUS Transformer), either pre 4.0 or post 4.0, the downloaded file is called "download.php", not "AIR FOR PIPES.MP3". In other words the browser ignores the attachment filename. At least the song plays fine even with the .php suffix! Curiously on a Samsung Charge Android 2.3.6 phone the filename is "AIR_FOR_PIPES.MP3" (the phone added the underscores which is fine). On windows, this code works fine on IE, Firefox, Chrome and Safari. Only the tablet is giving me grief with the filename.

其他网站都建议我必须有后无空间;和MP3必须在盖 - 既不是解决方案。其他信息表明这是一个已知的bug与职位,但你可以看到我做的只是GET。我也曾尝试指定应用程序/八位字节流,但它并没有差异。

Other sites have suggested I must have no space after the ";" and mp3 must be in caps - neither is the solution. Other information suggests this is a known bug with POST but as you can see I am doing only GET. I have also tried specifying "application/octet-stream" but it makes no diff.

是否有导致该文件最初被称为无题,但最终存储的download.php的一些平板电脑的设置? (我的平板电脑是加密的 - 不知道这是有关)

Is there some tablet setting that is causing the file to initially be called "Untitled" but ultimately stored as "download.php"? (My tablet is encrypted - not sure if that is relevant.)

编辑/答:(论坛不会让我回答我的问题)
显然,平板电脑不会容忍在附加文件名的空间。我删除他们和文件名是否正确记录为AIRFORPIPES.MP3。

EDIT/ANSWER: (forum won't let me answer my own question) Apparently the tablet will not tolerate spaces in the attached filename. I removed them and the filename was recorded correctly as AIRFORPIPES.MP3.

推荐答案

本次论坛现在让我回答我的问题。正如我在编辑上面提到的Andr​​oid平板电脑将不接受文件名的空间,也不会接受下划线,甚至想到了Droid手机转换为下划线的空间! Android平板转换AIR%20FOR%20PIPES于空气管道,但Droid手机将其转换为AIR 20FOR 20PIPES所以真正通用的解决方案是在发送头之前从文件名中删除空格。

The forum will now let me answer my own question. As mentioned above in my EDIT the Android tablet will not accept spaces in the filename, nor will it accept underscores, even thought the Droid phone converts the spaces to underscores! The Android tablet converts AIR%20FOR%20PIPES to AIR FOR PIPES but the Droid phone converts it to AIR 20FOR 20PIPES so really the generic solution is remove spaces from the filename before sending the header.

这篇关于Android的HTTP头附件的文件名被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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