S3 Client

S3 Client

Service Suite allows you to use the Amazon S3 (https://aws.amazon.com/s3/) which is a highly stable file repository.

In order to create an S3 Client from Service Suite you need to create a client

 s3client = createS3Client(filename) 

The filename is a properties file with the access key and secret key values. Similar to

AWS_ACCESS_KEY_ID=xxxxxxx
AWS_SECRET_ACCESS_KEY=yyyyyyyyyyyyyyyyyyyyyyy

The access key and secret access key are usual AWS access keys (https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html ).

The S3 Client methods are:

download(bucket:String, remoteName:String) → byte[]

downloadFile(bucket:String, remoteName:String, localpath:String)

downloadFile(bucket:String, remoteName:String, localpath:String)

list(bucket:String, prefix:String) → Set<String>

listFolders(bucket:String, prefix:String) → Set<String>

listFolderNames(bucket:String, prefix:String) → Set<String>

upload(bucket:String, data:byte[], remoteName:String)

var client = createS3Client("{ds}/s3.creds");
var bucketName ="myBucket";   // this must exist in S3
var data = "user,pass\njohn,doe";
// client.delete(bucketName, "test.csv");   // delete previous file 
client.upload(bucketName, toByteArray(data), "test.csv");

uploadPublic(bucket:String, data:byte[], remoteName:String)