Use access points or Multi-Region Access Points
After Amazon S3 access points or Multi-Region Access Points are set up, you can call object methods, such as
putObject
and getObject
and provide the access point
identifier instead of a bucket name.
For example, if an access point ARN identifier is
arn:aws:s3:us-west-2:123456789012:accesspoint/test
, you can use the
following snippet to call the putObject
method.
Path path = Paths.get(URI.create("file:///temp/file.txt")); s3Client.putObject(builder -> builder .key("myKey") .bucket("arn:aws:s3:us-west-2:123456789012:accesspoint/test") , path);
In place of the ARN string, you can also use the bucket-style alias of the access point for the bucket
parameter.
To use Multi-Region Access Point, replace the bucket
parameter with the
Multi-Region Access Point ARN that has the following format.
arn:aws:s3::account-id:accesspoint/MultiRegionAccessPoint_alias
Add the following Maven dependency to work with Multi-Region Access Points using the
SDK for Java. Search maven central for the latest version
<dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>auth-crt</artifactId> <version>
VERSION
</version> </dependency>