Skip to main content

How do I use the AWS SDK for Java V2 with Tenbyte T2?

You can take advantage of Tenbyte T2 Cloud Storage using the AWS SDK for Java V2 alongside the Tenbyte S3-Compatible API. The following example shows a configuration with the Tenbyte S3-compatible endpoint:
Note: Make sure to replace ACCESS_KEY and SECRET_ACCESS_KEY with your actual Tenbyte T2 Access Key ID and Secret Access Key from your Tenbyte console.
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;

import java.net.URI;

public class TenbyteT2Example {

    public static void main(String[] args) {

        final String ACCESS_KEY = "<T2-keyId>";
        final String SECRET_ACCESS_KEY = "<T2-appKey>";
        final String END_POINT = "https://t2.tenbytecloud.com";

        Region region = Region.US_EAST_1;

        AwsSessionCredentials awsCreds = AwsSessionCredentials.create(
            ACCESS_KEY,
            SECRET_ACCESS_KEY,
            ""
        );

        S3Client s3 = S3Client.builder()
            .credentialsProvider(StaticCredentialsProvider.create(awsCreds))
            .endpointOverride(URI.create(END_POINT))
            .region(region)
            .build();

        // s3 client is now ready to use with Tenbyte T2
        System.out.println("Successfully connected to Tenbyte T2");
    }
}
The Tenbyte S3-Compatible API allows thousands of integrations to natively work with Tenbyte T2 Cloud Storage. If you are new to the Tenbyte S3-Compatible API, refer to the Getting Started guide. If you have issues using this SDK with Tenbyte T2, contact us at support@tenbyte.io.