ECS Java SDK
The ECS Java SDK is built on the Jersey REST client, and it supports the ECS API extensions.
An example of using this SDK (S3Client) is shown below.
package com.emc.ecs.s3.sample;
import com.emc.object.s3.*;
import com.emc.object.s3.jersey.S3JerseyClient;
import java.net.URI;
public class S3ClientSample {
public static void main(String[] args) throws Exception {
URI endpoint = new URI("http://ecs.yourco.com:9020");
String accessKey = "fred@yourco.com";
String secretKey = "pcQQ20rDI2DHZOIWNkAug3wK4XJP9sQnZqbQJev3";
S3Config config = new S3Config(endpoint);
config.withIdentity(accessKey).withSecretKey(secretKey);
S3Client s3Client = new S3JerseyClient(config);
S3ClientSample sample = new S3ClientSample(s3Client);
sample.runSample();
}
private final S3Client s3Client;
public S3ClientSample(S3Client s3Client) {
this.s3Client = s3Client;
}
public void runSample() {
String bucketName = "mybucket";
String key1 = "test1.txt";
String content = "Hello World!";
try {
s3Client.createBucket(bucketName);
s3Client.putObject(bucketName, key1, content, "text/plain");
} catch (S3Exception e) {
// handle errors
}
}
}