3

I can set 'Cache-Control'(meta data) of a particular file and a particular bucket in amazon S3.

But I want that Cache-Control to be set for every file in a particular folder(not the entire bucket, but only folder).

Also when I upload a new file in that particular folder, Cache-Control header gets automatically set for the new file. I have followed this and S3 Documentation.

Is there any way by which this can be achieved?

FreeFly
  • 41
  • 1
  • 6
  • 1
    Possible duplicate of [Set cache-control for entire S3 bucket automatically (using bucket policies?)](http://stackoverflow.com/questions/10435334/set-cache-control-for-entire-s3-bucket-automatically-using-bucket-policies) – Joe Jul 20 '16 at 11:17
  • 1
    @Joe I want changes for the entire folder, not the enitre bucket, but the entire folder. – FreeFly Jul 21 '16 at 12:23
  • HI @FreeFly any news about that? – imanis_tn Jan 04 '17 at 10:51

2 Answers2

3

Based on another question's answer here I found that with this tool we can run a recursive for all files in a particular folder, but this won't be applied for the new files.

steps:

git clone https://github.com/s3tools/s3cmd

Run s3cmd --configure

(You will be asked for the two keys - copy and paste them from your confirmation email or from your Amazon account page. Be careful when copying them! They are case sensitive and must be entered accurately or you'll keep getting errors about invalid signatures or similar. Remember to add s3:ListAllMyBuckets permissions to the keys or you will get an AccessDenied error while testing access.)

./s3cmd --recursive modify --add-header="Cache-Control:public ,max-age= 31536000" s3://your_bucket_name/

imanis_tn
  • 1,150
  • 1
  • 12
  • 33
1

@FreeFly

It seems like with the new updates to the S3 console UI, there is now an option to add metadata on a directory, and doing so will recursively apply metadata to each object within that directory.

Go to

  1. Your Bucket
  2. Check object (can be a directory)
  3. Click on Select and from the dropdown menu select Edit metadata
  4. then select Add metadata and enter metadata
  5. Click on Edit Metadata. and this should recursively apply metadata to all objects inside current directory.
Rushi patel
  • 522
  • 7
  • 17