We have around 10,000+ images in a bucket in Amazon S3, how can I set the expires header on all of the images in one go?
相关问题
- How to upload images from the browser to Amazon S3
- How to start pm2 website using jenkins on AWS ubun
- DevPay and Mfa are mutually exclusive authorizatio
- Scala & DataBricks: Getting a list of Files
- Load Image from Stream/StreamReader to Image OR Ra
相关文章
- how many objects are returned by aws s3api list-ob
- AWS S3 in rails - how to set the s3_signature_vers
- PUT to S3 with presigned url gives 403 error
- php - unlink throws error: Resource temporarily un
- AWS CLI s3 copy fails with 403 error, trying to ad
- Amazon Athena - Column cannot be resolved on basic
- Pre-signed URLs and x-amz-acl
- How do I read a csv stored in S3 with csv.DictRead
Pretty sure it's not possible to do this in a single request. Instead you'll have to make 10,000 PUT requests, one for each key, with the new headers/metadata you want along with the
x-amz-copy-source
header pointing to the same key (so that you don't need to re-upload the object). The link I provided goes into more detail on the PUT-copy operation, but it's pretty much the way to change object metadata on s3.Cyberduck will edit headers as well.
Just processed 6000 images in one bucket without a hitch.
You can make bulk changes to bucket files with third party apps that use the S3 API. Those apps will not set the headers using only one request, but will automate the 10,000+ required requests.
The one I currently use is Cloudberry Explorer, which is a freeware utility to interact with your S3 buckets. In this tool I can select multiple files and specify HTTP headers that will be applied to all of them.
An alternative would be to develop your own script or tool using the S3 API libraries.
An alternative solution is to add
response-expires
parameter in your URL. It sets theExpires
header of the response.See Request Parameters section in http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html for more detail.
Just a heads up that I found a great solution using the AWS CLI:
This will set the Cache-Control for 30 days. Note that you have the option to copy or replace the previous header data. Since AWS will automatically include the right meta content-type data for each media type and I had some bad headers I just chose to overwrite everything.