Storage and Backup - Using aws sdk (java 2.x) to access S3/Swift Object Storage
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Frage

Using aws sdk (java 2.x) to access S3/Swift Object Storage

Von
ANDREAM1
Erstellungsdatum 2022-07-26 09:28:23 (edited on 2024-09-04 14:25:46) in Storage and Backup

Is Swift Object Storage compatible with the "standard" aws sdk (v. 2.0) ?

Here my code to create a S3Client:
AwsBasicCredentials awsCreds = AwsBasicCredentials.create(
"accessKeyId",
"secretAccessKey");

client = S3Client.builder()
.credentialsProvider(StaticCredentialsProvider.create(awsCreds))
.region(????)
.build();

I found my accessKeyId and secretAccessKey, but I can't set a proper vaue for "region", because it is NOT a string, but an instance of software.amazon.awssdk.regions.Region class, that has a predefined values only (I think I should pass "gra").
Does that mean I cannot use this sdk? Do I have to use the REST API?


1 Antwort ( Latest reply on 2026-04-07 06:26:56 Von
henry jame
)

Hi, solved by myself!
Use this code:

Region gra = Region.of("gra");

client = S3Client.builder()
.region(gra)
.endpointOverride(URI.create("https://s3.gra.cloud.ovh.net"))
.credentialsProvider(StaticCredentialsProvider.create(awsCreds))
.build();

Yes, you can use the AWS SDK for Java (2.x) with OVHcloud Object Storage, but only if you use the S3-compatible endpoint, not pure Swift.

OVHcloud provides S3-compatible APIs for Object Storage, so standard tools and SDKs (like AWS SDK) will work — but you must configure them correctly.

👉 The key points:

  • Use the S3 endpoint format:

     
    https://s3.<region>.cloud.ovh.net
     
  • Set the region as a valid AWS SDK region object (even if OVH uses custom names like gra, you still need to map it properly in the SDK).
  • Most importantly, override the endpoint URL in the client config — otherwise it will try to connect to AWS instead of OVH.

💡 Also note:

  • OVH’s Swift storage is older and not fully aligned with AWS SDK expectations.
  • For new projects, OVH themselves recommend using S3-compatible Object Storage instead of Swift for better compatibility and fewer issues.