Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
    *
    * Licensed under the Apache License, Version 2.0 (the "License").
    * You may not use this file except in compliance with the License.
    * A copy of the License is located at
    *
    *  http://aws.amazon.com/apache2.0
    *
   * or in the "license" file accompanying this file. This file is distributed
   * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
   * express or implied. See the License for the specific language governing
   * permissions and limitations under the License.
   */
  package com.amazonaws.services.s3.model;
  
  import java.util.Date;
  import java.util.List;
  

Provides options for copying an Amazon S3 object from a source location to a new destination.

All CopyObjectRequests must specify a source bucket and key, along with a destination bucket and key. Beyond that, requests also specify:

  • Object metadata for new object,
  • A CannedAccessControlList for the new object,
  • Constraints controlling if the copy will be performed or not.

  
  public class CopyObjectRequest extends AmazonWebServiceRequest implements
The name of the bucket containing the object to be copied
  
      private String sourceBucketName;

    
The key in the source bucket under which the object to be copied is stored
  
      private String sourceKey;

    
Optional version Id specifying which version of the source object to copy. If not specified, the most recent version of the source object will be copied.

For more information about enabling versioning for a bucket, see com.amazonaws.services.s3.AmazonS3.setBucketVersioningConfiguration(com.amazonaws.services.s3.model.SetBucketVersioningConfigurationRequest).

  
      private String sourceVersionId;

    
The name of the bucket to contain the copy of the source object
  
      private String destinationBucketName;

    
The key in the destination bucket under which the source object will be copied
  
      private String destinationKey;

    
The optional Amazon S3 storage class to use when storing the newly copied object. If not specified, the default, standard storage class will be used.

For more information on Amazon S3 storage classes and available values, see the StorageClass enumeration.

  
      private String storageClass;

    
Optional field specifying the object metadata for the new object
  
      private ObjectMetadata newObjectMetadata;

    
Optional field specifying the ACL for the new object
  
      private CannedAccessControlList cannedACL;

    
An optional access control list to apply to the new object. If specified, cannedAcl will be ignored.
  
      private AccessControlList accessControlList;

    
Optional list of ETag values that constrain the copy request to only be executed if the source object's ETag matches one of the specified ETag values.
 
     private List<StringmatchingETagConstraints = new ArrayList<String>();

    
Optional list of ETag values that constrain the copy request to only be executed if the source object's ETag does not match any of the specified ETag constraint values.
 
     private List<StringnonmatchingEtagConstraints = new ArrayList<String>();

    
Optional field that constrains the copy request to only be executed if the source object has not been modified since the specified date.
 
     private Date unmodifiedSinceConstraint;

    
Optional field that constrains the copy request to only be executed if the source object has been modified since the specified date.
 
     private Date modifiedSinceConstraint;

    
Optional field specifying the redirect location for the new object
 
     private String redirectLocation;

    
The optional customer-provided server-side encryption key to use to decrypt the source object being copied.
 
     private SSECustomerKey sourceSSECustomerKey;

    
The optional customer-provided server-side encryption key to use to encrypt the destination object being copied.
 
     private SSECustomerKey destinationSSECustomerKey;

    
The optional AWS Key Management system parameters to be used to encrypt the the object on the server side.
 

Constructs with basic options.

Parameters:
sourceBucketName The name of the S3 bucket containing the object to copy.
sourceKey The source bucket key under which the object to copy is stored.
destinationBucketName The name of the S3 bucket to which the new object will be copied.
destinationKey The destination bucket key under which the new object will be copied.
 
     public CopyObjectRequest(String sourceBucketNameString sourceKey,
                              String destinationBucketNameString destinationKey) {
         this(sourceBucketNamesourceKeynulldestinationBucketNamedestinationKey);
     }

    

Constructs a new CopyObjectRequest with basic options, providing an S3 version ID identifying the specific version of the source object to copy.

Parameters:
sourceBucketName The name of the S3 bucket containing the object to copy.
sourceKey The key in the source bucket under which the object to copy is stored.
sourceVersionId The S3 version ID which uniquely identifies a specific version of the source object to copy.
destinationBucketName The name of the S3 bucket in which the new object will be copied.
destinationKey The key in the destination bucket under which the new object will be copied.
See also:
CopyObjectRequest.CopyObjectRequest(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
 
     public CopyObjectRequest(String sourceBucketNameString sourceKeyString sourceVersionId,
                              String destinationBucketNameString destinationKey) {
         this. = sourceBucketName;
         this. = sourceKey;
         this. = sourceVersionId;
         this. = destinationBucketName;
         this. = destinationKey;
     }

    
Gets the name of the bucket containing the source object to be copied.

Returns:
The name of the bucket containing the source object to be copied.
See also:
setSourceBucketName(java.lang.String)
 
     public String getSourceBucketName() {
         return ;
     }

    
Sets the name of the bucket containing the source object to be copied.

Parameters:
sourceBucketName The name of the bucket containing the source object to be copied.
See also:
getSourceBucketName()
 
     public void setSourceBucketName(String sourceBucketName) {
         this. = sourceBucketName;
     }

    
Sets the name of the bucket containing the source object to be copied, and returns this object, enabling additional method calls to be chained together.

Parameters:
sourceBucketName The name of the bucket containing the source object to be copied.
Returns:
This CopyObjectRequest instance, enabling additional method calls to be chained together.
 
     public CopyObjectRequest withSourceBucketName(String sourceBucketName) {
         setSourceBucketName(sourceBucketName);
         return this;
     }

    
Gets the source bucket key under which the source object to be copied is stored.

Returns:
The source bucket key under which the source object to be copied is stored.
See also:
setSourceKey(java.lang.String)
 
     public String getSourceKey() {
         return ;
     }

    
Sets the source bucket key under which the source object to be copied is stored.

Parameters:
sourceKey The source bucket key under which the source object to be copied is stored.
See also:
setSourceKey(java.lang.String)
 
     public void setSourceKey(String sourceKey) {
         this. = sourceKey;
     }

    
Sets the key in the source bucket under which the source object to be copied is stored and returns this object, enabling additional method calls to be chained together.

Parameters:
sourceKey The key in the source bucket under which the source object to be copied is stored.
Returns:
This CopyObjectRequest instance, enabling additional method calls to be chained together.
 
     public CopyObjectRequest withSourceKey(String sourceKey) {
         setSourceKey(sourceKey);
         return this;
     }

    

Gets the version ID specifying which version of the source object to copy. If not specified, the most recent version of the source object will be copied.

Objects created before enabling versioning or when versioning is suspended are given the default null version ID (see com.amazonaws.services.s3.internal.Constants.NULL_VERSION_ID). Note that the null version ID is a valid version ID and is not the same as not having a version ID.

For more information about enabling versioning for a bucket, see com.amazonaws.services.s3.AmazonS3.setBucketVersioningConfiguration(com.amazonaws.services.s3.model.SetBucketVersioningConfigurationRequest).

Returns:
The version ID specifying which version of the source object to copy.
See also:
com.amazonaws.services.s3.internal.Constants.NULL_VERSION_ID
setSourceVersionId(java.lang.String)
 
     public String getSourceVersionId() {
         return ;
     }

    

Sets the optional version ID specifying which version of the source object to copy. If not specified, the most recent version of the source object will be copied.

Objects created before enabling versioning or when versioning is suspended are given the default null version ID (see com.amazonaws.services.s3.internal.Constants.NULL_VERSION_ID). Note that the null version ID is a valid version ID and is not the same as not having a version ID.

For more information about enabling versioning for a bucket, see com.amazonaws.services.s3.AmazonS3.setBucketVersioningConfiguration(com.amazonaws.services.s3.model.SetBucketVersioningConfigurationRequest).

Parameters:
sourceVersionId The optional version ID specifying which version of the source object to copy.
 
     public void setSourceVersionId(String sourceVersionId) {
         this. = sourceVersionId;
     }

    

Sets the optional version ID specifying which version of the source object to copy and returns this object, enabling additional method calls to be chained together. If not specified, the most recent version of the source object will be copied.

Objects created before enabling versioning or when versioning is suspended are given the default null version ID (see com.amazonaws.services.s3.internal.Constants.NULL_VERSION_ID). Note that the null version ID is a valid version ID and is not the same as not having a version ID.

For more information about enabling versioning for a bucket, see com.amazonaws.services.s3.AmazonS3.setBucketVersioningConfiguration(com.amazonaws.services.s3.model.SetBucketVersioningConfigurationRequest).

Parameters:
sourceVersionId The optional version ID specifying which version of the source object to copy.
Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
     public CopyObjectRequest withSourceVersionId(String sourceVersionId) {
         setSourceVersionId(sourceVersionId);
         return this;
     }

    
Gets the destination bucket name which will contain the new, copied object.

Returns:
The name of the destination bucket which will contain the new, copied object.
See also:
setDestinationBucketName(java.lang.String)
 
     public String getDestinationBucketName() {
         return ;
     }

    
Sets the destination bucket name which will contain the new, copied object.

Parameters:
destinationBucketName The name of the destination bucket which will contain the new, copied object.
See also:
getDestinationBucketName()
 
     public void setDestinationBucketName(String destinationBucketName) {
         this. = destinationBucketName;
     }

    
Sets the name of the destination bucket which will contain the new, copied object and returns this object, enabling additional method calls to be chained together.

Parameters:
destinationBucketName The name of the destination bucket which will contain the new, copied object.
Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
     public CopyObjectRequest withDestinationBucketName(String destinationBucketName) {
         setDestinationBucketName(destinationBucketName);
         return this;
     }

    
Gets the destination bucket key under which the new, copied object will be stored.

Returns:
The destination bucket key under which the new, copied object will be stored.
See also:
setDestinationKey(java.lang.String)
 
     public String getDestinationKey() {
         return ;
     }

    
Sets the destination bucket key under which the new, copied object will be stored.

Parameters:
destinationKey The destination bucket key under which the new, copied object will be stored.
See also:
getDestinationKey()
 
     public void setDestinationKey(String destinationKey) {
         this. = destinationKey;
     }

    
Sets the destination bucket key under which the new, copied object will be stored and returns this object, enabling additional method calls can be chained together.

Parameters:
destinationKey The destination bucket key under which the new, copied object will be stored.
Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
     public CopyObjectRequest withDestinationKey(String destinationKey) {
         setDestinationKey(destinationKey);
         return this;
     }
 
     /*
      * Optional Request Properties
      */

    

Gets the optional Amazon S3 storage class to use when storing the newly copied object. If not specified, the default standard storage class is used.

For more information on available Amazon S3 storage classes, see the StorageClass enumeration.

Returns:
The Amazon S3 storage class to use when storing the newly copied object.
See also:
setStorageClass(java.lang.String)
setStorageClass(com.amazonaws.services.s3.model.StorageClass)
 
     public String getStorageClass() {
         return ;
     }

    

Sets the optional Amazon S3 storage class to use when storing the newly copied object. If not specified, the default standard storage class is used.

For more information on Amazon S3 storage classes and available values, see the StorageClass enumeration.

 
     public void setStorageClass(String storageClass) {
         this. = storageClass;
     }

    

Sets the optional Amazon S3 storage class to use when storing the newly copied object and returns this CopyObjectRequest, enabling additional method calls to be chained together. If not specified, the default standard storage class is used.

For more information on Amazon S3 storage classes and available values, see the StorageClass enumeration.

Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
     public CopyObjectRequest withStorageClass(String storageClass) {
         setStorageClass(storageClass);
         return this;
     }

    

Sets the optional Amazon S3 storage class to use when storing the newly copied object. If not specified, the default standard storage class is used.

For more information on Amazon S3 storage classes and available values, see the StorageClass enumeration.

 
     public void setStorageClass(StorageClass storageClass) {
         this. = storageClass.toString();
     }

    

Sets the optional Amazon S3 storage class to use when storing the newly copied object and returns this CopyObjectRequest, enabling additional method calls to be chained together. If not specified, the default standard storage class is used.

For more information on Amazon S3 storage classes and available values, see the StorageClass enumeration.

Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
     public CopyObjectRequest withStorageClass(StorageClass storageClass) {
         setStorageClass(storageClass);
         return this;
     }

    
Gets the canned ACL to use for the new, copied object. If no canned ACL is specified, S3 will default to using the CannedAccessControlList.Private canned ACL for all copied objects.

Returns:
The canned ACL to set for the newly copied object, or null if no canned ACL has been specified.
 
         return ;
     }

    
Sets the canned ACL to use for the newly copied object. If no canned ACL is specified, S3 will default to using the CannedAccessControlList.Private canned ACL for all copied objects.

Parameters:
cannedACL The canned ACL to set for the newly copied object.
 
     public void setCannedAccessControlList(CannedAccessControlList cannedACL) {
         this. = cannedACL;
     }

    
Sets the canned ACL to use for the newly copied object, and returns this CopyObjectRequest, enabling additional method calls to be chained together.

Parameters:
cannedACL The canned ACL to set for the newly copied object.
Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
         setCannedAccessControlList(cannedACL);
         return this;
     }

    
Returns the optional access control list for the new object. If specified, cannedAcl will be ignored.
 
         return ;
     }

    
Sets the optional access control list for the new object. If specified, cannedAcl will be ignored.

Parameters:
accessControlList The access control list for the new object.
 
     public void setAccessControlList(AccessControlList accessControlList) {
         this. = accessControlList;
     }

    
Sets the optional access control list for the new object. If specified, cannedAcl will be ignored. Returns this CopyObjectRequest, enabling additional method calls to be chained together.

Parameters:
accessControlList The access control list for the new object.
 
     public CopyObjectRequest withAccessControlList(AccessControlList accessControlList) {
         setAccessControlList(accessControlList);
         return this;
     }

    
Gets the optional object metadata to set for the new, copied object.

Returns:
The object metadata to set for the newly copied object. Returns null if no object metadata has been specified.
See also:
setNewObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata)
 
     public ObjectMetadata getNewObjectMetadata() {
         return ;
     }

    
Sets the object metadata to use for the new, copied object. By default the object metadata from the source object is copied to the destination object, but when setting object metadata with this method, no metadata from the source object is copied. Instead, the new destination object will have the metadata specified with this call.

Parameters:
newObjectMetadata The object metadata to use for the newly copied object.
See also:
getNewObjectMetadata()
 
     public void setNewObjectMetadata(ObjectMetadata newObjectMetadata) {
         this. = newObjectMetadata;
     }

    
Sets the object metadata to use for the new, copied object and returns this object, enabling additional method calls to be chained together. By default, the object metadata from the source object will be copied to the destination object, but if callers set object metadata with this method, it will be used instead.

Parameters:
newObjectMetadata The object metadata to use for the newly copied object.
Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
     public CopyObjectRequest withNewObjectMetadata(ObjectMetadata newObjectMetadata) {
         setNewObjectMetadata(newObjectMetadata);
         return this;
     }
 
     /*
      * Optional Constraints
      */

    

Gets the optional list of ETag constraints that, when present, must include a match for the source object's current ETag in order for the copy object request to be executed. Only one ETag in the list needs to match for the request to be executed by Amazon S3.

Matching ETag constraints may be used with the unmodified since constraint, but not with any other type of constraint.

Returns:
The optional list of ETag constraints that when present must include a match for the source object's current ETag in order for this request to be executed.
 
     public List<StringgetMatchingETagConstraints() {
         return ;
     }

    

Sets the optional list of ETag constraints that, when present, must include a match for the source object's current ETag in order for the copy object request to be executed. If none of the specified ETags match the source object's current ETag, the copy object operation will be aborted. Only one ETag in the list needs to match for the request to be executed by Amazon S3.

Matching ETag constraints may be used with the unmodified since constraint, but not with any other type of constraint.

Parameters:
eTagList The optional list of ETag constraints that must include a match for the source object's current ETag in order for this request to be executed.
 
     public void setMatchingETagConstraints(List<StringeTagList) {
         this. = eTagList;
     }

    

Adds a single ETag constraint to this request and returns this object, enabling additional method calls to be chained together. Multiple ETag constraints can be added to a request, but one must match the source object's current ETag in order for the copy object request to be executed. If none of the ETag constraints added to this request match the source object's current ETag, the copy object operation will be aborted.

Matching ETag constraints may be used with the unmodified since constraint, but not with any other type of constraint.

Parameters:
eTag The matching ETag constraint to add to this request.
Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
         this..add(eTag);
         return this;
     }

    

Gets the optional list of ETag constraints that, when present, must not include a match for the source object's current ETag in order for the copy object request to be executed. If any entry in the non-matching ETag constraint list matches the source object's current ETag, this copy request will not be executed by Amazon S3.

Non-matching ETag constraints may be used with the modified since constraint, but not with any other type of constraint.

Returns:
The optional list of ETag constraints that when present must not include a match for the source object's current ETag in order for this request to be executed.
 
         return ;
     }

    

Sets the optional list of ETag constraints that, when present, must not include a match for the source object's current ETag in order for the copy object request to be executed. If any entry in the non-matching ETag constraint list matches the source object's current ETag, this copy request will not be executed by Amazon S3.

Non-matching ETag constraints may be used with the modified since constraint, but not with any other type of constraint.

Parameters:
eTagList The list of ETag constraints that, when present, must not include a match for the source object's current ETag in order for this request to be executed.
 
     public void setNonmatchingETagConstraints(List<StringeTagList) {
         this. = eTagList;
     }

    

Adds a single ETag constraint to this request and returns this object, enabling additional method calls to be chained together. Multiple ETag constraints can be added to a request, but all ETag constraints must not match the source object's current ETag in order for the copy object request to be executed. If any entry in the non-matching ETag constraint list matches the source object's current ETag, this copy request will not be executed by Amazon S3.

Non-matching ETag constraints may be used with the modified since constraint, but not with any other type of constraint.

Parameters:
eTag The non-matching ETag constraint to add to this request.
Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
         this..add(eTag);
         return this;
     }

    

Gets the optional unmodified constraint that restricts this request to executing only if the source object has not been modified after the specified date.

The unmodified since constraint may be used with matching ETag constraints, but not with any other type of constraint.

Returns:
The optional unmodified constraint that restricts this request to executing only if the source object has not been modified after the specified date.
 
     public Date getUnmodifiedSinceConstraint() {
         return ;
     }

    

Sets the optional unmodified constraint that restricts this request to executing only if the source object has not been modified after the specified date.

The unmodified constraint may be used with matching ETag constraints, but not with any other type of constraint.

Note that Amazon S3 will ignore any dates occurring in the future.

Parameters:
date The unmodified constraint that restricts this request to executing only if the source object has not been modified after this date.
 
     public void setUnmodifiedSinceConstraint(Date date) {
         this. = date;
     }

    

Sets the optional unmodified constraint that restricts this request to executing only if the source object has not been modified after the specified date. Returns this object, enabling additional method calls to be chained together.

The unmodified constraint may be used with matching ETag constraints, but not with any other type of constraint.

Note that Amazon S3 will ignore any dates occurring in the future.

Parameters:
date The unmodified constraint that restricts this request to executing only if the source object has not been modified after this date.
Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
         setUnmodifiedSinceConstraint(date);
         return this;
     }

    

Gets the optional modified constraint that restricts this request to executing only if the source object has been modified after the specified date.

The modified constraint may be used with non-matching ETag constraints, but not with any other type of constraint.

Returns:
The optional modified constraint that restricts this request to executing only if the source object has been modified after the specified date.
 
     public Date getModifiedSinceConstraint() {
         return ;
     }

    

Sets the optional modified constraint that restricts this request to executing only if the source object has been modified after the specified date.

The modified constraint may be used with non-matching ETag constraints, but not with any other type of constraint.

Note that Amazon S3 will ignore any dates occurring in the future.

Parameters:
date The modified constraint that restricts this request to executing only if the source object has been modified after the specified date.
 
     public void setModifiedSinceConstraint(Date date) {
         this. = date;
     }

    

Sets the optional modified constraint that restricts this request to executing only if the source object has been modified after the specified date. Returns this object, enabling additional method calls to be chained together.

The modified constraint may be used with non-matching ETag constraints, but not with any other type of constraint.

Note that Amazon S3 will ignore any dates occurring in the future.

Parameters:
date The modified constraint that restricts this request to executing only if the source object has been modified after the specified date.
Returns:
This CopyObjectRequest, enabling additional method calls to be chained together.
 
         setModifiedSinceConstraint(date);
         return this;
     }

    
Sets the optional redirect location for the newly copied object.

Parameters:
redirectLocation The redirect location for the newly copied object.
 
     public void setRedirectLocation(String redirectLocation) {
         this. = redirectLocation;
     }

    
Gets the optional redirect location for the newly copied object.
 
     public String getRedirectLocation() {
         return this.;
     }

    
Sets the optional redirect location for the newly copied object.Returns this CopyObjectRequest, enabling additional method calls to be chained together.

Parameters:
redirectLocation The redirect location for the newly copied object.
 
     public CopyObjectRequest withRedirectLocation(String redirectLocation) {
         this. = redirectLocation;
         return this;
     }

    
Returns the optional customer-provided server-side encryption key to use to decrypt the source object being copied.

Returns:
The optional customer-provided server-side encryption key to use to decrypt the source object being copied.
 
         return ;
     }

    
Sets the optional customer-provided server-side encryption key to use to decrypt the source object being copied.

Parameters:
sseKey The optional customer-provided server-side encryption key to use to decrypt the source object being copied.
    public void setSourceSSECustomerKey(SSECustomerKey sseKey) {
        this. = sseKey;
    }

    
Sets the optional customer-provided server-side encryption key to use to decrypt the source object being copied, and returns the updated request object so that additional method calls can be chained together.

Parameters:
sseKey The optional customer-provided server-side encryption key to use to decrypt the source object being copied.
Returns:
This updated request object so that additional method calls can be chained together.
        setSourceSSECustomerKey(sseKey);
        return this;
    }

    
Returns the optional customer-provided server-side encryption key to use to encrypt the destination object being copied.

Returns:
The optional customer-provided server-side encryption key to use to encrypt the destination object being copied.
        return ;
    }

    
Sets the optional customer-provided server-side encryption key to use to encrypt the destination object being copied.

Parameters:
sseKey The optional customer-provided server-side encryption key to use to encrypt the destination object being copied.
    public void setDestinationSSECustomerKey(SSECustomerKey sseKey) {
        if (sseKey != null && this. != null) {
            throw new IllegalArgumentException(
                "Either SSECustomerKey or SSEAwsKeyManagementParams must not be set at the same time.");
        }
        this. = sseKey;
    }

    
Sets the optional customer-provided server-side encryption key to use to encrypt the destination object being copied, and returns the updated request object so that additional method calls can be chained together.

Parameters:
sseKey The optional customer-provided server-side encryption key to use to encrypt the destination object being copied.
Returns:
This updated request object so that additional method calls can be chained together.
        setDestinationSSECustomerKey(sseKey);
        return this;
    }

    
Returns the AWS Key Management System parameters used to encrypt the object on server side.
    @Override
        return ;
    }

    
Sets the AWS Key Management System parameters used to encrypt the object on server side.
        if (params != null && this. != null) {
            throw new IllegalArgumentException(
                "Either SSECustomerKey or SSEAwsKeyManagementParams must not be set at the same time.");
        }
        this. = params;
    }

    
Sets the AWS Key Management System parameters used to encrypt the object on server side.

Returns:
returns the update CopyObjectRequest
            SSEAwsKeyManagementParams sseAwsKeyManagementParams) {
        setSSEAwsKeyManagementParams(sseAwsKeyManagementParams);
        return this;
    }
New to GrepCode? Check out our FAQ X