jcaddel / maven-s3-wagon

Multi-threaded wagon to connect Maven with Amazon S3
123 stars 50 forks source link

permissions support #1

Closed carrot-garden closed 12 years ago

carrot-garden commented 12 years ago

hi;

do you think it is feasible to add support for full range of permissions? currently you have only "public"

        request.setCannedAcl(CannedAccessControlList.PublicRead);

see

        com.amazonaws.services.s3.model.CannedAccessControlList

thanks.

/**
 * Create a PutObjectRequest based on the source file and destination passed in
 */
protected PutObjectRequest getPutObjectRequest(File source, String destination, TransferProgress progress) {
    try {
        String key = getNormalizedKey(source, destination);
        String bucketName = bucket.getName();
        InputStream input = getInputStream(source, progress);
        ObjectMetadata metadata = getObjectMetadata(source, destination);
        PutObjectRequest request = new PutObjectRequest(bucketName, key, input, metadata);
        request.setCannedAcl(CannedAccessControlList.PublicRead);
        return request;
    } catch (FileNotFoundException e) {
        throw new AmazonServiceException("File not found", e);
    }
}
jcaddel commented 12 years ago

Excellent idea! How/where does Maven supply information like this to a wagon? Configured via the xml related to a server in settings.xml perhaps?

carrot-garden commented 12 years ago

thank you for considering this;

here is what I found:

1) basic user guide: http://maven.apache.org/guides/mini/guide-http-settings.html#Support_for_General-Wagon_Configuration_Standards

2) use case example: http://brettporter.wordpress.com/2009/06/16/configuring-maven-http-connections/

3) how to inject settings.xml properties into wagon: https://github.com/apache/maven-wagon/blob/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java

/**
 * @plexus.configuration
 */
private Properties httpHeaders;
jcaddel commented 12 years ago

Version 1.1.9 supports configurable ACL's. S3 objects are created with PublicRead by default, but that can now be overridden through configuration.

Add <acl></acl> to the configuration for a server in settings.xml to change the default:

For example:

<server>
  <id>s3.snapshot</id>
  <configuration>
    <acl>AuthenticatedRead</acl>
  </configuration>
</server>

The value for the <acl> parameter must be one of the enum values for

com.amazonaws.services.s3.model.CannedAccessControlList

In the version of the AWS SDK used by the wagon (1.2.15) the allowed values for that enum are:

 Private
 PublicRead
 PublicReadWrite 
 AuthenticatedRead 
 LogDeliveryWrite
 BucketOwnerRead
 BucketOwnerFullControl