Example usage for com.amazonaws.services.s3.model CreateBucketRequest withCannedAcl

List of usage examples for com.amazonaws.services.s3.model CreateBucketRequest withCannedAcl

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model CreateBucketRequest withCannedAcl.

Prototype

public CreateBucketRequest withCannedAcl(CannedAccessControlList cannedAcl) 

Source Link

Document

Sets the optional Canned ACL to set for the new bucket, and returns this updated object so that additional method calls can be chained together.

Usage

From source file:org.entando.entando.plugins.jps3awsclient.aps.system.services.storage.AmazonS3StorageManager.java

License:Open Source License

public void checkForAndCreateBucket(String bucketName, AmazonS3Client client) {
    // Make sure it's lower case to comply with Amazon S3 recommendations
    bucketName = bucketName.toLowerCase();
    if (this._bucketMap.get(bucketName) == null) {
        if (client.doesBucketExist(bucketName)) {
            this._bucketMap.put(bucketName, true);
        } else {//from   w w w  .  jav  a2  s.co  m
            // Bucket hasn't been created yet so we create it
            CreateBucketRequest request = new CreateBucketRequest(bucketName);
            request.withCannedAcl(CannedAccessControlList.LogDeliveryWrite);
            client.createBucket(request);
            this._bucketMap.put(bucketName, true);
        }
    }
}

From source file:org.plos.repo.service.S3StoreService.java

License:Open Source License

@Override
public Optional<Boolean> createBucket(Bucket bucket) {
    try {/* w  ww  .j  a va2 s  .  c o m*/
        CreateBucketRequest bucketRequest = new CreateBucketRequest(bucket.getBucketName(), Region.US_West);
        bucketRequest.withCannedAcl(CannedAccessControlList.PublicRead);
        s3Client.createBucket(bucketRequest);

        return TRUE;
    } catch (Exception e) {
        log.error("Error creating bucket", e);
        return FALSE;
    }
}