Package com.amazon.s3

Examples of com.amazon.s3.AWSAuthConnection


  }

  @Override
  public void deleteAttachment(ERS3Attachment attachment)
      throws MalformedURLException, IOException {
    AWSAuthConnection conn = attachment.awsConnection();
    String bucket = attachment.bucket();
    String key = attachment.key();
    Response response = conn.delete(bucket, key, null);
    if (failed(response)) {
      throw new IOException("Failed to delete '" + bucket + "/" + key
          + "' to S3: Error " + response.connection.getResponseCode()
          + ": " + response.connection.getResponseMessage());
    }
View Full Code Here


  public void performUpload(File uploadedFile, String originalFileName,
      String bucket, String key, String mimeType,
      ERS3Attachment attachment) throws MalformedURLException,
      IOException {
    try {
      AWSAuthConnection conn = attachment.awsConnection();
      FileInputStream attachmentFileInputStream = new FileInputStream(
          uploadedFile);
      BufferedInputStream attachmentInputStream = new BufferedInputStream(
          attachmentFileInputStream);
      try {
        S3StreamObject attachmentStreamObject = new S3StreamObject(
            attachmentInputStream, null);

        Map<String, List<String>> headers = new TreeMap<String, List<String>>();
        headers.put("Content-Type",
            Arrays.asList(new String[] { mimeType }));
        headers.put("Content-Length", Arrays
            .asList(new String[] { String.valueOf(uploadedFile
                .length()) }));
        headers.put("x-amz-acl",
            Arrays.asList(new String[] { attachment.acl() }));

        if (originalFileName != null) {
          headers.put("Content-Disposition", Arrays
              .asList(new String[] { "attachment; filename="
                  + originalFileName }));
        }

        Response response = conn.putStream(bucket, key,
            attachmentStreamObject, headers);
        if (failed(response)) {
          throw new IOException("Failed to write '" + bucket + "/"
              + key + "' to S3: Error "
              + response.connection.getResponseCode() + ": "
View Full Code Here

    String host = ERXProperties.stringForKey("er.attachment." + configurationName() + ".s3.host");
    if (host == null) {
      host = ERXProperties.stringForKey("er.attachment.s3.host");
    }
    if (host == null)
      return new AWSAuthConnection(accessKeyID(), secretAccessKey(), true);
    else
      return new AWSAuthConnection(accessKeyID(), secretAccessKey(), true, host);
  }
View Full Code Here

    CanonicalUser owner = new CanonicalUser();
    owner.setID(enginePolicy.getOwner().getID());
    owner.setDisplayName(enginePolicy.getOwner().getDisplayName());
    policy.setOwner(owner);
   
    AccessControlList acl = new AccessControlList();
    acl.setGrant(toGrants(enginePolicy.getGrants()));
    policy.setAccessControlList(acl);
    return policy;
  }
View Full Code Here

    response.setGetObjectAccessControlPolicyResponse(toAccessControlPolicy(policy));
    return response;
  }
 
  private static AccessControlPolicy toAccessControlPolicy(S3AccessControlPolicy enginePolicy) {
    AccessControlPolicy policy = new AccessControlPolicy();
    CanonicalUser owner = new CanonicalUser();
    owner.setID(enginePolicy.getOwner().getID());
    owner.setDisplayName(enginePolicy.getOwner().getDisplayName());
    policy.setOwner(owner);
   
    AccessControlList acl = new AccessControlList();
    acl.setGrant(toGrants(enginePolicy.getGrants()));
    policy.setAccessControlList(acl);
    return policy;
  }
View Full Code Here

        entries[i].setKey(engineEntries[i].getKey());
        entries[i].setLastModified(engineEntries[i].getLastModified());
        entries[i].setSize(engineEntries[i].getSize());
        entries[i].setStorageClass(StorageClass.STANDARD);
       
        CanonicalUser owner = new CanonicalUser();
        owner.setID(engineEntries[i].getOwnerCanonicalId());
        owner.setDisplayName(engineEntries[i].getOwnerDisplayName());
        entries[i].setOwner(owner);
      }
      return entries;
    }
   
View Full Code Here

    ListAllMyBucketsResponse response = new ListAllMyBucketsResponse();
    ListAllMyBucketsResult result = new ListAllMyBucketsResult();
    ListAllMyBucketsEntry[] entries = null;
   
    S3CanonicalUser ownerEngine = engineResponse.getOwner();
    CanonicalUser owner = new CanonicalUser();
    owner.setID(ownerEngine.getID());
    owner.setDisplayName(ownerEngine.getDisplayName());
    result.setOwner(owner);
    S3ListAllMyBucketsEntry[] engineEntries = engineResponse.getBuckets();
    if (engineEntries != null) {
      entries = new ListAllMyBucketsEntry[engineEntries.length];
      for(int i = 0; i < engineEntries.length; i++) {
View Full Code Here

    return response;
  }
 
  private static AccessControlPolicy toAccessControlPolicy(S3AccessControlPolicy enginePolicy) {
    AccessControlPolicy policy = new AccessControlPolicy();
    CanonicalUser owner = new CanonicalUser();
    owner.setID(enginePolicy.getOwner().getID());
    owner.setDisplayName(enginePolicy.getOwner().getDisplayName());
    policy.setOwner(owner);
   
    AccessControlList acl = new AccessControlList();
    acl.setGrant(toGrants(enginePolicy.getGrants()));
    policy.setAccessControlList(acl);
View Full Code Here

      {
        grants[i] = new Grant();
       
        switch( engineGrants[i].getGrantee()) {
        case SAcl.GRANTEE_USER :
           grantee = new CanonicalUser();
           ((CanonicalUser)grantee).setID(engineGrants[i].getCanonicalUserID());
           ((CanonicalUser)grantee).setDisplayName("TODO");
           grants[i].setGrantee(grantee);
           break;
         
View Full Code Here

    response.setPutObjectInlineResponse(result);
    return response;
  }
 
  public static CopyObjectResponse toCopyObjectResponse(S3CopyObjectResponse engineResponse) throws AxisFault {
    CopyObjectResponse response = new CopyObjectResponse();
    int resultCode = engineResponse.getResultCode();

    CopyObjectResult result = new CopyObjectResult();   
    if ( 300 <= resultCode )
    {
         String description = engineResponse.getResultDescription();
       throw new AxisFault( "" + resultCode, (null == description ? "" : description));
    }
   
    result.setETag( "\"" + engineResponse.getETag() + "\"" );
    result.setLastModified(engineResponse.getLastModified());    
    response.setCopyObjectResult(result);
    return response;
  }
View Full Code Here

TOP

Related Classes of com.amazon.s3.AWSAuthConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.