我怎样才能改变只对音频文件的AWS S3的内容类型 [英] How can i change AWS S3 content type only for audio files

查看:553
本文介绍了我怎样才能改变只对音频文件的AWS S3的内容类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有50000以上文件(音频,图像,PDF)的AWS S3 bucket.Now我面临着Firefox的一个问题。因为它们的内容类型的音频文件是不是在玩的Firefox。它运作良好之前。

I have above 50000 files ( audio, images, pdf) on AWS S3 bucket.Now i am facing a problem with firefox. Audio file is not playing on firefox because of their content-type. Before it was working well.

音频文件的工作很好,当我改变内容类型,从二进制/八位字节流的到的音频/ MPEG 的。

Audio file works good when i change the content-type from binary/octet-stream to audio/mpeg.

默认的内容类型(二进制/八位字节流)被分配给所有现有文件。

The default content-type ( binary/octet-stream ) is assigned for all existing files.

我也试过S3存储资源管理器工具,但目前还没有选项可以更改内容类型的专为音频文件

I also tried s3 bucket explorer tool but there are no option to change the content-type specifically for audio files.

如何更改内容类型仅适用于音频文件?

是否有通过AWS PHP SDK任何例子吗?

在此先感谢

推荐答案

我也碰到了这个问题,并作为撰文指出,这是用来解决它的办法 s3cmd 工具:

I also ran into this problem, and as the author pointed out, this is the way to fix it using the s3cmd tool:

s3cmd --recursive modify                             \ 
    --acl-public                                     \
    --add-header='Cache-Control: max-age=94608000'   \
    --add-header='content-type':'audio/mpeg'         \
    --exclude '' --include '.mp3'                    \
    s3://<your-bucket-name>/                         \

- 递归修改标志告诉s3cmd撤换到你的水桶,并找到修改的所有文件; - ACL公开开放,供公众查阅修改后的文件; - 附加头='的Cache-Control 设置以秒为单位的时间量的高速缓存可以保留的文件(这样的人从你的水桶得到该文件将不再需要下载第二次,如果文件没有改变)。 - 排除''--includeMP3指示s3cmd排除从流程中的所有文件,除了那些与指定模式匹配。下面是另一个例子,在你的水桶设置所有的CSS文件为text / css的:

The --recursive modify flag tells s3cmd to recuse into your bucket and find all files to modify; --acl-public opens modified files for public access; --add-header='Cache-Control sets the amount of time in seconds the cache can keep the file (so people getting the file from your bucket won't need to download it a second time, if the file hasn't changed). --exclude '' --include 'mp3' instructs s3cmd to exclude all files from the process, except the ones matching the specified pattern. Here is another example, setting all css files in your bucket to text/css:

s3cmd --recursive modify --add-header='content-type':'text/css' \
      --exclude '' --include '.css' s3://<your-bucket-name>/

如果你不知道什么样的内容类型,以指定特定的文件类型,检查出的最常见的MIME类型列表:的 http://hul.harvard.edu/ois/systems/wax/wax-公众帮助/ mimetypes.htm

If you are not sure what kind of content-type to specify for your specific type of file, check out this list of most common mimetypes: http://hul.harvard.edu/ois/systems/wax/wax-public-help/mimetypes.htm

这篇关于我怎样才能改变只对音频文件的AWS S3的内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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