Example usage for com.amazonaws.services.s3 AmazonS3Client AmazonS3Client

List of usage examples for com.amazonaws.services.s3 AmazonS3Client AmazonS3Client

Introduction

In this page you can find the example usage for com.amazonaws.services.s3 AmazonS3Client AmazonS3Client.

Prototype

@SdkInternalApi
AmazonS3Client(AmazonS3ClientParams s3ClientParams) 

Source Link

Document

Constructs a new client to invoke service methods on S3 using the specified parameters.

Usage

From source file:org.deeplearning4j.aws.s3.uploader.S3Uploader.java

License:Apache License

/**
 * Multi part upload for big files/*from w  w  w.jav  a  2 s  . c o m*/
 * @param file the file to upload
 * @param bucketName the bucket name to upload
 */
public void multiPartUpload(File file, String bucketName) {
    AmazonS3 client = new AmazonS3Client(creds);
    bucketName = ensureValidBucketName(bucketName);

    List<Bucket> buckets = client.listBuckets();
    for (Bucket b : buckets)
        if (b.getName().equals(bucketName)) {
            doMultiPart(client, bucketName, file);
            return;
        }

    //bucket didn't exist: create it
    client.createBucket(bucketName);
    doMultiPart(client, bucketName, file);
}

From source file:org.deeplearning4j.aws.s3.uploader.S3Uploader.java

License:Apache License

/**
 * Upload the file to the bucket./* w w w  . j a va2  s .com*/
 * Will create the bucket if it hasn't already been created
 * @param file the file to upload
 * @param bucketName the name of the bucket
 */
public void upload(File file, String bucketName) {
    AmazonS3 client = new AmazonS3Client(creds);
    bucketName = ensureValidBucketName(bucketName);

    List<Bucket> buckets = client.listBuckets();
    for (Bucket b : buckets)
        if (b.getName().equals(bucketName)) {
            client.putObject(bucketName, file.getName(), file);
            return;
        }

    //bucket didn't exist: create it
    client.createBucket(bucketName);
    client.putObject(bucketName, file.getName(), file);

}