如何更改 Amazon S3 对象的内容类型 [英] How to change content type of Amazon S3 Objects

查看:31
本文介绍了如何更改 Amazon S3 对象的内容类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Amazon S3 存储桶中的对象都是内容类型 application/octet-stream.其中一些对象是 PDF,有时是图像,如 JPGGIFPNG.如何将这些对象的内容类型更改为 images/jpegapplication/pdf 等?

The objects in my Amazon S3 bucket are all of the content type application/octet-stream. Some of these objects are PDFs, sometimes images like JPG, GIF, PNG. How can I change the content type of these objects to images/jpeg, application/pdf etc.?

是否可以通过亚马逊控制台批量完成?

Can it be done in batch through the Amazon Console?

我可以使用命令行吗?

或者也许通过 PHP?

Or maybe through PHP?

推荐答案

这是您可以为 *.png 类型的所有文件设置 Content-Type 的方法

This is how you can set Content-Type for all files of type *.png

aws s3 cp 
       s3://BUCKET-NAME/ 
       s3://BUCKET-NAME/ 
       --exclude '*' 
       --include '*.png' 
       --no-guess-mime-type 
       --content-type="image/png" 
       --metadata-directive="REPLACE" 
       --recursive

这篇关于如何更改 Amazon S3 对象的内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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