Skip to content

EmadAlblueshi/object-storage-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object Storage Client

Build Status

A convenient S3 client based on Vert.x that is compatible with Amazon S3 REST API protocol

Warning
The module in active development, this means the API can change between versions.

Example

// Create auth options
var authOptions = new S3AuthOptions()
    .setSignatureVersion(SignatureVersion.V4)
    .setAccessKey("access-key")
    .setSecretKey("secret-key");

// Create client options
var clientOptions = new S3ClientOptions()
    .setAuthOptions(authOptions)
    .setRegion("kw-west-1")
    .setHost("s3.example.com")
    .setPort(443)
    .setSsl(true);

// Create the client
var client = S3Client.create(vertx, clientOptions);

// Create new general purpose bucket
client.putBucket(new BucketOptions(), "/my-bucket").onComplete(r -> {
  if (r.succeeded()) {
    System.out.println("Bucket created");
  } else {
    System.out.println("Bucket failed");
  }
});

// Create object request options
var objectOptions = new ObjectOptions()
    .contentType("text/plain")
    .storageClass(StorageClass.STANDARD)
    .acl(Acl.PUBLIC_READ);

// Read an existing text file
Buffer fileBuffer = vertx.fileSystem().readFileBlocking("example.txt");

// Create new object
client.put(objectOptions, "/my-bucket/my-object.txt", fileBuffer).onComplete(r -> {
  if (r.succeeded()) {
    System.out.println("Object created");
  } else {
    System.out.println("Object failed");
  }
});

Building

To launch the tests:

mvn clean test

To package:

mvn clean package -DskipTests

To package with site

mvn clean package -DskipTests site