Cross-origin Resource Sharing

Cross-origin Resource Sharing (CORS) is used for sharing resources between different domains. We can use the resources of one domain in another domain by keeping the CORS support enabled. CORS is achieved by creating rules and assigning those rules to the bucket.

First of all, we need to create CORSRule:

.... CORSRule.AllowedMethods[] allowedMethods1 = new CORSRule.AllowedMethods[] {CORSRule.AllowedMethods.GET, CORSRule.AllowedMethods.PUT, CORSRule.AllowedMethods.POST, CORSRule.AllowedMethods.DELETE}; String[] allowedOrigins1 = new String[] {"http://*.sunilgulabani.com"}; CORSRule rule1 = createRule("Sunil Gulabani Website Rule",allowedOrigins1,allowedMethods1,null,-1); .... private CORSRule createRule( String id, ...

Get Amazon S3 Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.