AWS SDK for Java
The AWS SDK for Java
Before you start
- Create a service account.
- Add the service account to a group to grant it necessary permissions.
- Create a static access key.
Installation
To install the AWS SDK for JAVA, follow the instructions
Setup
-
Go to the
~/.aws/
directory (for macOS and Linux) orC:\Users\<username>\.aws\
(for Windows). -
Create a file named
credentials
with authentication data for Object Storage and copy the following information to it:[default] aws_access_key_id = <static_key_ID> aws_secret_access_key = <secret_key>
-
Create a file named
config
with the default region parameters and copy the following information to it:[default] region=eu-north1
Note
Some apps designed to work with Amazon S3 don't let you set the region, so Object Storage also accepts the value
us-east-1
.
To access Object Storage, use the https://storage.ai.nebius.cloud
endpoint.
Code samples
For a code sample, see aws-java-sdk/samples/AmazonS3
in the archive with the SDK distribution package.
To connect to Object Storage, replace the code in the sample:
AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withRegion("us-west-2")
.build();
to
AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withEndpointConfiguration(
new AmazonS3ClientBuilder.EndpointConfiguration(
"storage.ai.nebius.cloud","eu-north1"
)
)
.build();