Example #1
0
 /**
  * This implementation invokes {@link S3Client#putObject}
  *
  * @param container bucket name
  * @param blob object
  */
 @Override
 public String putBlob(String container, Blob blob) {
   PutObjectOptions options = new PutObjectOptions();
   AccessControlList acl = bucketAcls.get(container);
   if (acl != null && acl.hasPermission(GroupGranteeURI.ALL_USERS, Permission.READ))
     options.withAcl(CannedAccessPolicy.PUBLIC_READ);
   return sync.putObject(container, blob2Object.apply(blob), options);
 }
  private ListenableFuture<String> putBlobWithReducedRedundancy(String container, Blob blob) {
    AWSS3PutObjectOptions options = new AWSS3PutObjectOptions();
    try {
      AccessControlList acl = bucketAcls.getUnchecked(container);
      if (acl != null
          && acl.hasPermission(
              AccessControlList.GroupGranteeURI.ALL_USERS, AccessControlList.Permission.READ)) {
        options.withAcl(CannedAccessPolicy.PUBLIC_READ);
      }
      options.storageClass(ObjectMetadata.StorageClass.REDUCED_REDUNDANCY);

    } catch (CacheLoader.InvalidCacheLoadException e) {
      // nulls not permitted from cache loader
    }
    return getContext()
        .unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN)
        .getAsyncApi()
        .putObject(container, blob2Object.apply(blob), options);
  }