Example usage for com.amazonaws.services.s3.model S3ObjectId S3ObjectId

List of usage examples for com.amazonaws.services.s3.model S3ObjectId S3ObjectId

Introduction

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

Prototype

public S3ObjectId(String bucket, String key, String versionId) 

Source Link

Usage

From source file:org.mule.module.s3.S3Connector.java

License:Open Source License

/**
 * Deletes a given object, only the owner of the bucket containing the version
 * can perform this operation. If version is specified, versioning must be
 * enabled, and once deleted, there is no method to restore such version.
 * Otherwise, once deleted, the object can only be restored if versioning was
 * enabled when the object was deleted. If attempting to delete an object that
 * does not exist, Amazon S3 will return a success message instead of an error
 * message.//from w  w  w  .  j  a v  a 2  s  .  c  o  m
 *
 * {@sample.xml ../../../doc/mule-module-s3.xml.sample s3:delete-object}
 * 
 * @param bucketName the object's bucket
 * @param key the object's key
 * @param versionId the specific version of the object to delete, if versioning
 *            is enabled. Left unspecified if the latest version is desired, or
 *            versioning is not enabled.
 */
@Processor
public void deleteObject(String bucketName, String key, @Optional String versionId) {
    client.deleteObject(new S3ObjectId(bucketName, key, versionId));
}

From source file:org.mule.module.s3.S3Connector.java

License:Open Source License

/**
 * Copies a source object to a new destination; to copy an object, the caller's
 * account must have read access to the source object and write access to the
 * destination bucket. By default, all object metadata for the source object are
 * copied to the new destination object, unless new object metadata in the
 * specified is provided. The AccesControlList is not copied to the new object,
 * and, unless another ACL specified, PRIVATE is assumed. If no destination
 * bucket is specified, the same that the source bucket is used - local copy.
 *
 * {@sample.xml ../../../doc/mule-module-s3.xml.sample s3:copy-object}
 *
 * @param sourceBucketName the source object's bucket
 * @param sourceKey the source object's key
 * @param sourceVersionId the specific version of the source object to copy, if
 *            versioning is enabled. Left unspecified if the latest version is
 *            desired, or versioning is not enabled.
 * @param destinationBucketName the destination object's bucket. If none
 *            provided, a local copy is performed, that is, it is copied within
 *            the same bucket.//  w  ww. j ava  2s .  c o m
 * @param destinationKey the destination object's key
 * @param destinationAcl the acl of the destination object.
 * @param destinationStorageClass one of {@link StorageClass} enumerated values, defaults to {@link StorageClass#STANDARD}
 * @param destinationUserMetadata the new metadata of the destination object,
 *            that if specified, overrides that copied from the source object
 * @param modifiedSince The modified constraint that restricts this request to
 *            executing only if the object has been modified after the specified
 *            date. This constraint is specified but does not match, no copy is performed
 * @param unmodifiedSince The unmodified constraint that restricts this request
 *            to executing only if the object has not been modified after this
 *            date. This constraint is specified but does not match, no copy is performed
 * @param encryption Encryption method for server-side encryption. Supported value AES256.
 * @return the version id of the new object, or null, if versioning is not
 *         enabled
 */
@Processor
public String copyObject(String sourceBucketName, String sourceKey, @Optional String sourceVersionId,
        @Optional String destinationBucketName, String destinationKey,
        @Default("PRIVATE") AccessControlList destinationAcl,
        @Default("STANDARD") StorageClass destinationStorageClass,
        @Optional Map<String, String> destinationUserMetadata, @Optional Date modifiedSince,
        @Optional Date unmodifiedSince, @Optional String encryption) {
    return client.copyObject(new S3ObjectId(sourceBucketName, sourceKey, sourceVersionId),
            new S3ObjectId(coalesce(destinationBucketName, sourceBucketName), destinationKey),
            ConditionalConstraints.from(modifiedSince, unmodifiedSince), destinationAcl.toS3Equivalent(),
            destinationStorageClass.toS3Equivalent(), destinationUserMetadata, encryption);
}

From source file:org.mule.module.s3.S3Connector.java

License:Open Source License

/**
 * Returns a pre-signed URL for accessing an Amazon S3 object. The pre-signed URL
 * can be shared to other users, allowing access to the resource without
 * providing an account's AWS security credentials.
 *
 * {@sample.xml ../../../doc/mule-module-s3.xml.sample s3:create-object-presigned-uri}
 *
 * @param bucketName the object's bucket
 * @param key the object's key/*from w  w  w  . j av a  2s.co  m*/
 * @param versionId the specific version of the object to create the URI, if
 *            versioning is enabled. Left unspecified if the latest version is
 *            desired, or versioning is not enabled.
 * @param expiration The time at which the returned pre-signed URL will expire.
 * @param method The HTTP method verb to use for this URL
 * @return A non null pre-signed URI that can be used to access an Amazon S3
 *         resource without requiring the user of the URL to know the account's
 *         AWS security credentials.
 */
@Processor
public URI createObjectPresignedUri(String bucketName, String key, @Optional String versionId,
        @Optional Date expiration, @Default("PUT") String method) {
    return client.createObjectPresignedUri(new S3ObjectId(bucketName, key, versionId), expiration,
            toHttpMethod(method));
}

From source file:org.mule.module.s3.S3Connector.java

License:Open Source License

/**
 * Gets the content of an object stored in Amazon S3 under the specified bucket
 * and key. Returns null if the specified constraints weren't met. To get an
 * object's content from Amazon S3, the caller must have {@link Permission#Read}
 * access to the object. Regarding conditional get constraints, Amazon S3 will
 * ignore any dates occurring in the future.
 *
 * {@sample.xml ../../../doc/mule-module-s3.xml.sample s3:get-object-content}
 * /*from ww w.  j a  v a2s.  co m*/
 * @param bucketName the object's bucket
 * @param key the object's key
 * @param versionId the specific version of the object to get its contents, if
 *            versioning is enabled, left unspecified if the latest version is
 *            desired, or versioning is not enabled.
 * @param modifiedSince The modified constraint that restricts this request to
 *            executing only if the object has been modified after the specified
 *            date.
 * @param unmodifiedSince The unmodified constraint that restricts this request
 *            to executing only if the object has not been modified after this
 *            date.
 * @return an input stream to the objects contents
 */
@Processor
public S3ObjectInputStream getObjectContent(String bucketName, String key, @Optional String versionId,
        @Optional Date modifiedSince, @Optional Date unmodifiedSince) {
    return client.getObjectContent(new S3ObjectId(bucketName, key, versionId),
            ConditionalConstraints.from(modifiedSince, unmodifiedSince));
}

From source file:org.mule.module.s3.S3Connector.java

License:Open Source License

/**
 * Gets the object stored in Amazon S3 under the specified bucket and key.
 * Returns null if the specified constraints weren't met. To get an object from
 * Amazon S3, the caller must have {@link Permission#Read} access to the object.
 * Callers should be very careful when using this method; the returned Amazon S3
 * object contains a direct stream of data from the HTTP connection. The
 * underlying HTTP connection cannot be closed until the user finishes reading
 * the data and closes the stream. Regarding conditional get constraints, Amazon
 * S3 will ignore any dates occurring in the future.
 *
 * {@sample.xml ../../../doc/mule-module-s3.xml.sample s3:get-object}
 * /*from   w w  w .j a  v a2 s  .  c o  m*/
 * @param bucketName the object's bucket
 * @param key the object's key
 * @param versionId the specific version of the object to get its contents, if
 *            versioning is enabled. Left unspecified if the latest version is
 *            desired, or versioning is not enabled.
 * @param modifiedSince The modified constraint that restricts this request to
 *            executing only if the object has been modified after the specified
 *            date.
 * @param unmodifiedSince The unmodified constraint that restricts this request
 *            to executing only if the object has not been modified after this
 *            date.
 * @return the S3Object, or null, if conditional get constraints did not match
 */
@Processor
public S3Object getObject(String bucketName, String key, @Optional String versionId,
        @Optional Date modifiedSince, @Optional Date unmodifiedSince) {
    return client.getObject(new S3ObjectId(bucketName, key, versionId),
            ConditionalConstraints.from(modifiedSince, unmodifiedSince));
}

From source file:org.mule.module.s3.S3Connector.java

License:Open Source License

/**
 * Gets the metadata for the specified Amazon S3 object without actually fetching
 * the object itself. This is useful in obtaining only the object metadata, and
 * avoids wasting bandwidth on fetching the object data.
 *
 * {@sample.xml ../../../doc/mule-module-s3.xml.sample s3:get-object-metadata}
 * /* www  .  jav a2s .co  m*/
 * @param bucketName the object's bucket
 * @param key the object's key
 * @param versionId the object metadata for the given bucketName and key
 * @return the non null object metadata
 */
@Processor
public ObjectMetadata getObjectMetadata(String bucketName, String key, @Optional String versionId) {
    return client.getObjectMetadata(new S3ObjectId(bucketName, key, versionId));
}