Sample Java Code for using Content Gateway's S3 Interface

The zipped file referenced above contains everything you need to build Java source code samples that use the AWS Java SDK to list, upload (including S3 multipart), and download objects in a Swarm cluster. This requires a Content Gateway with the S3 port enabled.

First configure and test s3cmd [], to verify your access / secret keys are valid and that url resolution of your domain works. Your DNS must map your domain to your Content Gateway or https proxy.

Then just set the same endpoint, access key, and secret key environment variables when running maven to build and run a sample:




mvn compile exec:java

You can change the mainClass in pom.xml to run S3Sample, LowLevel_LargeObjectCopy, or gui S3TransferProgressSample. TODO: some configuration code needs to be updated to use non-deprecated methods.

These sample programs came from the AWS SDK or documentation. Really the only change needed to use a Swarm domain instead of AWS S3 is the addition of the line:


You might also have to set S3ClientOptions.setPathStyleAccess(true) to avoid certificate validation failures. This forces requests to be made to instead of

Some samples allow configuration of other options, such as connection timeouts or whether V4 signatures are used (tip: V4 is slower than V2).

The pom.xml specifies the latest 1.11.122 SDK but it should work as far back as 1.9

© DataCore Software Corporation. · · All rights reserved.