Skip to content

Instantly share code, notes, and snippets.

@jeremywall
Created October 1, 2022 03:19
Show Gist options
  • Save jeremywall/105af450c67f59a4c30a0f4d9da5b9c6 to your computer and use it in GitHub Desktop.
Save jeremywall/105af450c67f59a4c30a0f4d9da5b9c6 to your computer and use it in GitHub Desktop.
Set R2 Bucket CORS config using AWS Java SDK v2
CORSRule corsRule1 = CORSRule.builder()
.allowedMethods("GET","PUT", "POST")
.allowedOrigins("*")
.build();
PutBucketCorsResponse putResponse = s3Client.putBucketCors(
PutBucketCorsRequest.builder()
.bucket(bucketName)
.corsConfiguration(
CORSConfiguration.builder()
.corsRules(corsRule1)
.build()
)
.build()
);
GetBucketCorsResponse getResponse = s3Client.getBucketCors(
GetBucketCorsRequest.builder()
.bucket(bucketName)
.build()
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment