停止mp3文件在浏览器中流式传输 [英] Stop mp3 file from streaming in browsers
问题描述
这是否有标题的修复?或者是唯一的选择,所以'右键单击另存为'?
编辑这是我的标题。 Safari已经停止了流式传输,但是Chrome还是要做到这一点。
Chrome似乎忽略了这一点:
我可以看到标题已正确更改:
日期星期三,04八月2010 00:14:35 GMT
服务器Apache / 2.2.13(Unix)mod_ssl / 2.2.13 OpenSSL / 0.9.8e-fips-rhel5 mod_auth_passthrough /2.1 mod_bwlimited / 1.4 FrontPage / 5.0.2.2635 PHP / 5.2.11
最后修改的星期二,2010年8月3日04:37:01 GMT
Etag2bbd692-79597d-48ce3de3f5540
接受-Rars字节
内容长度7952765
内容处理附件
Keep-Alive timeout = 5,max = 100
连接Keep-Alive
内容类型音频/ mpeg
标题中是否还有其他可能会导致这种情况?
编辑进行了一些研究,我发现: http://www.google.com/support/forum/p/Chrome/thread?tid=76de4f53f43f03d3&hl=en
看起来可能是
你想设置 Content-Disposition
响应标题为附件,可能是文件名字段。
示例:
内容处理: 附件;文件名= foo.mp3;
要在Apache中直接完成此操作,请尝试将以下内容放在 httpd中。 conf
或 .htaccess
文件:
< FilesMatch\。(?i:mp3)$>
ForceType音频/ mpeg
SetEnvIf Request_URI^。* /?([^ /] *)$FILENAME = $ 1
标题集内容处置附件;文件名=%{FILENAME} e
UnsetEnv FILENAME
< / FilesMatch>
编辑
在Apache配置示例中添加了文件名字段,从这个答案。但是,您应该知道在其中包含非US-ASCII字符的文件名引起的潜在问题:请参阅这个问题。
或者,您可以使用通用常量文件名(因为你知道扩展名),如 song.mp3
,但根据您的具体情况,这可能不是一个选项。
第三个选择是创建一个脚本来提供这些MP3,它可以设置标题,并处理从文件名中删除不需要的字符。
I have an mp3 on an apache server. I want it to be downloaded as a file when a user visits the link. Instead quicktime, or google chromes media player will try and stream it.
Is there a fix for this with headers? Or is the only option so 'right click save as'?
Edit Here is my header. Safari has stopped streaming, but chrome contines to do it. Chrome seems to be ignoring this:
I can see the header has been changed correctly:
Date Wed, 04 Aug 2010 00:14:35 GMT
Server Apache/2.2.13 (Unix) mod_ssl/2.2.13 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.11
Last-Modified Tue, 03 Aug 2010 04:37:01 GMT
Etag "2bbd692-79597d-48ce3de3f5540"
Accept-Ranges bytes
Content-Length 7952765
Content-Disposition attachment
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Content-Type audio/mpeg
Is there anything else in the header that would cause this?
Edit Doing some research I found this: http://www.google.com/support/forum/p/Chrome/thread?tid=76de4f53f43f03d3&hl=en Looks like there might be a bug in chrome preventing it from downloading.
You want to set the Content-Disposition
response header to "attachment", and probably the "filename" field as well.
Example:
Content-Disposition: attachment; filename=foo.mp3;
To accomplish this directly in Apache, try putting the following in your httpd.conf
or .htaccess
file:
<FilesMatch "\.(?i:mp3)$">
ForceType audio/mpeg
SetEnvIf Request_URI "^.*/?([^/]*)$" FILENAME=$1
Header set Content-Disposition "attachment; filename=%{FILENAME}e"
UnsetEnv FILENAME
</FilesMatch>
EDIT:
Added filename field to Apache configuration example, borrowed from this answer. You should be aware, however, of potential problems caused by filenames with non-US-ASCII characters in them: see this question.
Alternatively, you could use a generic constant filename (since you know the extension already) like song.mp3
, but this might not be an option depending on your circumstances.
A third option would be to create a script to serve these MP3s, which can set the header and take care of stripping unwanted characters out of the filename.
这篇关于停止mp3文件在浏览器中流式传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!