I'm trying to get code working which sets an ACL on an object when I upload
it to the BlobStore. I'm using the Jclouds S3 provider, and the closest
documentation I can find is from the "Using S3" example code at
http://jclouds.apache.org/guides/aws/:
// when you need access to s3-specific features,// use the
provider-specific contextAWSS3Client s3Client =
AWSS3Client.class.cast(context.getProviderSpecificContext().getApi());
// make the object world readableString publicReadWriteObjectKey =
"public-read-write-acl";S3Object object = s3Client.newS3Object();
object.getMetadata().setKey(publicReadWriteObjectKey);object.setPayload("hello
world");s3Client.putObject(bucket, object,
withAcl(CannedAccessPolicy.PUBLIC_READ));
context.close();
Problem is, the getProviderSpecificContext()
<http://demobox.github.io/jclouds-maven-site-1.5.0/1.5.0/jclouds-multi/apidocs/org/jclouds/blobstore/BlobStoreContext.html#getProviderSpecificContext()>
method
was apparently removed in Jclouds 1.6. I think I can work around this using
contextBuilder.buildApi(S3Client.class) and the S3Object class to set the
ACL.
But then if I have to use an S3-specific API to set an ACL, why not just
use the com.amazonaws.services.s3.AmazonS3Client client directly? How is
Jclouds actually benefitting me, if I'm using it to code directly to the S3
provider?
*Steve Kingsland*
Senior Software Engineer
*Opower* <http://www.opower.com/>
*We’re hiring! See jobs here <http://www.opower.com/careers>*