Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we set CORS for folders in Amazon S3 Buckets

I've set permission on Bucket and CORS header is set on any file in root of the bucket but not for files inside a folder in Bucket. Is there a way to set CORS on files inside folder as well?

like image 497
Ashit Vora Avatar asked Nov 05 '15 11:11

Ashit Vora


People also ask

How do I configure CORS on my bucket?

In the Buckets list, choose the name of the bucket that you want to create a bucket policy for. Choose Permissions. In the Cross-origin resource sharing (CORS) section, choose Edit. In the CORS configuration editor text box, type or copy and paste a new CORS configuration, or edit an existing configuration.

What is S3 bucket CORS?

Cross-origin resource sharing (CORS) defines a way for client web applications that are loaded in one domain to interact with resources in a different domain. With CORS support, you can build rich client-side web applications with Amazon S3 and selectively allow cross-origin access to your Amazon S3 resources.

How do I add CORS in AWS?

Enable CORS support on a REST API resourceSign in to the API Gateway console at https://console.aws.amazon.com/apigateway . Choose the API from the APIs list. Choose a resource under Resources. This will enable CORS for all the methods on the resource.

Can you have folders in S3?

In Amazon S3, folders are used to group objects and organize files. Unlike a traditional file system, Amazon S3 doesn't use hierarchy to organize its objects and files. Amazon S3 console supports the folder concept only as a means of grouping (and displaying) objects.


1 Answers

If you have configured CORS on a bucket, then that configuration is active for all files in the bucket. S3 had no other options for CORS. If it appears that files outside the root don't have CORS active, you are almost certainly seeing cached responses, coming from somewhere other than S3 (which does not cache anything, itself).

like image 78
Michael - sqlbot Avatar answered Sep 29 '22 14:09

Michael - sqlbot