Created
October 1, 2022 03:19
-
-
Save jeremywall/105af450c67f59a4c30a0f4d9da5b9c6 to your computer and use it in GitHub Desktop.
Set R2 Bucket CORS config using AWS Java SDK v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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