Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-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.io.File;
 
Abstract base class for a put object or put object like request.
 
 public abstract class AbstractPutObjectRequest extends AmazonWebServiceRequest implements
The name of an existing bucket, to which this request will upload a new object. You must have Permission.Write permission granted to you in order to upload new objects to a bucket.
 
     private String bucketName;

    
The key under which to store the new object.
 
     private String key;

    
The file containing the data to be uploaded to Amazon S3. You must either specify a file or an InputStream containing the data to be uploaded to Amazon S3.
 
     private File file;

    
The InputStream containing the data to be uploaded to Amazon S3. You must either specify a file or an InputStream containing the data to be uploaded to Amazon S3.
 
     private InputStream inputStream;

    
Optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.). If you are uploading from an InputStream, you <bold>should always</bold> specify metadata with the content size set, otherwise the contents of the InputStream will have to be buffered in memory before they can be sent to Amazon S3, which can have very negative performance impacts.
 
     private ObjectMetadata metadata;

    
An optional pre-configured access control policy to use for the new object. Ignored in favor of accessControlList, if present.
 
     private CannedAccessControlList cannedAcl;

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

    
The optional Amazon S3 storage class to use when storing the new 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;

    
The optional redirect location about an object
 
     private String redirectLocation;

    
The optional customer-provided server-side encryption key to use to encrypt the uploaded object.
 
     private SSECustomerKey sseCustomerKey;

    
The optional AWS Key Management system parameters to be used to encrypt the the object on the server side.
 
Constructs a new AbstractPutObjectRequest object to upload a file to the specified bucket and key. After constructing the request, users may optionally specify object metadata or a canned ACL as well.

Parameters:
bucketName The name of an existing bucket to which the new object will be uploaded.
key The key under which to store the new object.
file The path of the file to upload to Amazon S3.
    public AbstractPutObjectRequest(String bucketNameString keyFile file) {
        this. = bucketName;
        this. = key;
        this. = file;
    }

    
Constructs a new AbstractPutObjectRequest object with redirect location. After constructing the request, users may optionally specify object metadata or a canned ACL as well.

Parameters:
bucketName The name of an existing bucket to which the new object will be uploaded.
key The key under which to store the new object.
redirectLocation The redirect location of this new object.
    public AbstractPutObjectRequest(String bucketNameString key,
            String redirectLocation) {
        this. = bucketName;
        this. = key;
        this. = redirectLocation;
    }

    
Constructs a new AbstractPutObjectRequest object to upload a stream of data to the specified bucket and key. After constructing the request, users may optionally specify object metadata or a canned ACL as well.

Content length for the data stream must be specified in the object metadata parameter; Amazon S3 requires it be passed in before the data is uploaded. Failure to specify a content length will cause the entire contents of the input stream to be buffered locally in memory so that the content length can be calculated, which can result in negative performance problems.

Parameters:
bucketName The name of an existing bucket to which the new object will be uploaded.
key The key under which to store the new object.
input The stream of data to upload to Amazon S3.
metadata The object metadata. At minimum this specifies the content length for the stream of data being uploaded.
    protected AbstractPutObjectRequest(String bucketNameString key,
            InputStream inputObjectMetadata metadata) {
        this. = bucketName;
        this. = key;
        this. = input;
        this. = metadata;
    }

    
Gets the name of the existing bucket where this request will upload a new object to. In order to upload the object, users must have Permission.Write permission granted.

Returns:
The name of an existing bucket where this request will upload a new object to.
See also:
setBucketName(java.lang.String)
withBucketName(java.lang.String)
    public String getBucketName() {
        return ;
    }

    
Sets the name of an existing bucket where this request will upload a new object to. In order to upload the object, users must have Permission.Write permission granted.

Parameters:
bucketName The name of an existing bucket where this request will upload a new object to. In order to upload the object, users must have Permission.Write permission granted.
See also:
getBucketName()
withBucketName(java.lang.String)
    public void setBucketName(String bucketName) {
        this. = bucketName;
    }

    
Sets the name of the bucket where this request will upload a new object to. Returns this object, enabling additional method calls to be chained together.

In order to upload the object, users must have Permission.Write permission granted.

Parameters:
bucketName The name of an existing bucket where this request will upload a new object to. In order to upload the object, users must have Permission.Write permission granted.
Returns:
This AbstractPutObjectRequest, enabling additional method calls to be chained together.
See also:
getBucketName()
setBucketName(java.lang.String)
    public <T extends AbstractPutObjectRequest> T withBucketName(
            String bucketName) {
        setBucketName(bucketName);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

    
Gets the key under which to store the new object.

Returns:
The key under which to store the new object.
See also:
setKey(java.lang.String)
withKey(java.lang.String)
    public String getKey() {
        return ;
    }

    
Sets the key under which to store the new object.

Parameters:
key The key under which to store the new object.
See also:
getKey()
withKey(java.lang.String)
    public void setKey(String key) {
        this. = key;
    }

    
Sets the key under which to store the new object. Returns this object, enabling additional method calls to be chained together.

Parameters:
key The key under which to store the new object.
Returns:
This AbstractPutObjectRequest, enabling additional method calls to be chained together.
See also:
getKey()
setKey(java.lang.String)
    public <T extends AbstractPutObjectRequest> T withKey(String key) {
        setKey(key);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

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

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

    public String getStorageClass() {
        return ;
    }

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

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 new object. Returns this AbstractPutObjectRequest, enabling additional method calls to be chained together. If not specified, the default standard storage class will be used when storing the object.

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

Parameters:
storageClass The storage class to use when storing the new object.
Returns:
This AbstractPutObjectRequest, enabling additional method calls to be chained together.
See also:
getStorageClass()
setStorageClass(com.amazonaws.services.s3.model.StorageClass)
setStorageClass(java.lang.String)
withStorageClass(com.amazonaws.services.s3.model.StorageClass)
    public <T extends AbstractPutObjectRequest> T withStorageClass(
            String storageClass) {
        setStorageClass(storageClass);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

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

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

Parameters:
storageClass The storage class to use when storing the new object.
See also:
getStorageClass()
setStorageClass(java.lang.String)
    public void setStorageClass(StorageClass storageClass) {
        this. = storageClass.toString();
    }

    
Sets the optional Amazon S3 storage class to use when storing the new object. Returns this AbstractPutObjectRequest, enabling additional method calls to be chained together. If not specified, the default standard storage class will be used when storing the object.

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

Parameters:
storageClass The storage class to use when storing the new object.
Returns:
This AbstractPutObjectRequest, enabling additional method calls to be chained together.
See also:
getStorageClass()
setStorageClass(com.amazonaws.services.s3.model.StorageClass)
setStorageClass(java.lang.String)
withStorageClass(java.lang.String)
    public <T extends AbstractPutObjectRequest> T withStorageClass(
            StorageClass storageClass) {
        setStorageClass(storageClass);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

    
Gets the path and name of the file containing the data to be uploaded to Amazon S3. Either specify a file or an input stream containing the data to be uploaded to Amazon S3; both cannot be specified.

Returns:
The path and name of the file containing the data to be uploaded to Amazon S3.
See also:
setFile(java.io.File)
withFile(java.io.File)
setInputStream(java.io.InputStream)
withInputStream(java.io.InputStream)
    @Override
    public File getFile() {
        return ;
    }

    
Sets the path and name of the file containing the data to be uploaded to Amazon S3. Either specify a file or an input stream containing the data to be uploaded to Amazon S3; both cannot be specified.

Parameters:
file The path and name of the file containing the data to be uploaded to Amazon S3.
See also:
getFile()
withFile(java.io.File)
getInputStream()
withInputStream(java.io.InputStream)
    @Override
    public void setFile(File file) {
        this. = file;
    }

    
Sets the file containing the data to be uploaded to Amazon S3. Returns this AbstractPutObjectRequest, enabling additional method calls to be chained together.

Either specify a file or an input stream containing the data to be uploaded to Amazon S3; both cannot be specified.

Parameters:
file The file containing the data to be uploaded to Amazon S3.
Returns:
This AbstractPutObjectRequest, enabling additional method calls to be chained together.
See also:
getFile()
setFile(java.io.File)
getInputStream()
setInputStream(java.io.InputStream)
    public <T extends AbstractPutObjectRequest> T withFile(File file) {
        setFile(file);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

    
Gets the optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.).

If uploading from an input stream, always specify metadata with the content size set. Otherwise the contents of the input stream have to be buffered in memory before being sent to Amazon S3. This can cause very negative performance impacts.

Returns:
The optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.).
See also:
setMetadata(com.amazonaws.services.s3.model.ObjectMetadata)
withMetadata(com.amazonaws.services.s3.model.ObjectMetadata)
    public ObjectMetadata getMetadata() {
        return ;
    }

    
Sets the optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.).

If uploading from an input stream, always specify metadata with the content size set. Otherwise the contents of the input stream have to be buffered in memory before being sent to Amazon S3. This can cause very negative performance impacts.

Parameters:
metadata The optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.).
See also:
getMetadata()
withMetadata(com.amazonaws.services.s3.model.ObjectMetadata)
    public void setMetadata(ObjectMetadata metadata) {
        this. = metadata;
    }

    
Sets the optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.). Returns this AbstractPutObjectRequest, enabling additional method calls to be chained together.

If uploading from an input stream, always specify metadata with the content size set. Otherwise the contents of the input stream have to be buffered in memory before being sent to Amazon S3. This can cause very negative performance impacts.

Parameters:
metadata The optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.).
Returns:
This AbstractPutObjectRequest, enabling additional method calls to be chained together.
See also:
getMetadata()
setMetadata(com.amazonaws.services.s3.model.ObjectMetadata)
    public <T extends AbstractPutObjectRequest> T withMetadata(
            ObjectMetadata metadata) {
        setMetadata(metadata);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

    
Gets the optional pre-configured access control policy to use for the new object.

Returns:
The optional pre-configured access control policy to use for the new object.
See also:
setCannedAcl(com.amazonaws.services.s3.model.CannedAccessControlList)
withCannedAcl(com.amazonaws.services.s3.model.CannedAccessControlList)
        return ;
    }

    
Sets the optional pre-configured access control policy to use for the new object.

Parameters:
cannedAcl The optional pre-configured access control policy to use for the new object.
See also:
getCannedAcl()
withCannedAcl(com.amazonaws.services.s3.model.CannedAccessControlList)
    public void setCannedAcl(CannedAccessControlList cannedAcl) {
        this. = cannedAcl;
    }

    
Sets the optional pre-configured access control policy to use for the new object. Returns this AbstractPutObjectRequest, enabling additional method calls to be chained together.

Parameters:
cannedAcl The optional pre-configured access control policy to use for the new object.
Returns:
This AbstractPutObjectRequest, enabling additional method calls to be chained together.
See also:
getCannedAcl()
setCannedAcl(com.amazonaws.services.s3.model.CannedAccessControlList)
    public <T extends AbstractPutObjectRequest> T withCannedAcl(
            CannedAccessControlList cannedAcl) {
        setCannedAcl(cannedAcl);
        @SuppressWarnings("unchecked") T t = (T) this;
        return t;
    }

    
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 AbstractPutObjectRequest, enabling additional method calls to be chained together.

Parameters:
accessControlList The access control list for the new object.
    public <T extends AbstractPutObjectRequest> T withAccessControlList(
            AccessControlList accessControlList) {
        setAccessControlList(accessControlList);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

    
Gets the input stream containing the data to be uploaded to Amazon S3. The user of this request must either specify a file or an input stream containing the data to be uploaded to Amazon S3; both cannot be specified.

Returns:
The input stream containing the data to be uploaded to Amazon S3. Either specify a file or an input stream containing the data to be uploaded to Amazon S3, not both.
See also:
setInputStream(java.io.InputStream)
withInputStream(java.io.InputStream)
setFile(java.io.File)
withFile(java.io.File)
    @Override
    public InputStream getInputStream() {
        return ;
    }

    
Sets the input stream containing the data to be uploaded to Amazon S3. Either specify a file or an input stream containing the data to be uploaded to Amazon S3; both cannot be specified.

Parameters:
inputStream The input stream containing the data to be uploaded to Amazon S3. Either specify a file or an input stream containing the data to be uploaded to Amazon S3, not both.
See also:
getInputStream()
withInputStream(java.io.InputStream)
getFile()
withFile(java.io.File)
    @Override
    public void setInputStream(InputStream inputStream) {
        this. = inputStream;
    }

    
Sets the input stream containing the data to be uploaded to Amazon S3. Returns this AbstractPutObjectRequest, enabling additional method calls to be chained together.

Either specify a file or an input stream containing the data to be uploaded to Amazon S3; both cannot be specified.

Parameters:
inputStream The InputStream containing the data to be uploaded to Amazon S3.
Returns:
This PutObjectRequest, so that additional method calls can be chained together.
See also:
getInputStream()
setInputStream(java.io.InputStream)
getFile()
setFile(java.io.File)
    public <T extends AbstractPutObjectRequest> T withInputStream(
            InputStream inputStream) {
        setInputStream(inputStream);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

    
Sets the optional redirect location for the new object.

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

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

    
Sets the optional redirect location for the new object.Returns this AbstractPutObjectRequest, enabling additional method calls to be chained together.

Parameters:
redirectLocation The redirect location for the new object.
    public <T extends AbstractPutObjectRequest> T withRedirectLocation(
            String redirectLocation) {
        this. = redirectLocation;
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }
    @Override
    public SSECustomerKey getSSECustomerKey() {
        return ;
    }

    
Sets the optional customer-provided server-side encryption key to use to encrypt the uploaded object.

Parameters:
sseKey The optional customer-provided server-side encryption key to use to encrypt the uploaded object.
    public void setSSECustomerKey(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 uploaded object, 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 uploaded object.
Returns:
This updated request object so that additional method calls can be chained together.
    public <T extends AbstractPutObjectRequest> T withSSECustomerKey(
            SSECustomerKey sseKey) {
        setSSECustomerKey(sseKey);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

    
Sets the optional progress listener for receiving updates for object upload status.

Deprecated:
use com.amazonaws.AmazonWebServiceRequest.setGeneralProgressListener(com.amazonaws.event.ProgressListener) instead.
Parameters:
progressListener The legacy progress listener that is used exclusively for Amazon S3 client.
    @Deprecated
    public void setProgressListener(com.amazonaws.services.s3.model.ProgressListener progressListener) {
        setGeneralProgressListener(new LegacyS3ProgressListener(progressListener));
    }

    
Returns the optional progress listener for receiving updates about object upload status.

Deprecated:
use com.amazonaws.AmazonWebServiceRequest.getGeneralProgressListener() instead.
Returns:
the optional progress listener for receiving updates about object upload status.
    @Deprecated
        ProgressListener generalProgressListener = getGeneralProgressListener();
        if (generalProgressListener instanceof LegacyS3ProgressListener) {
            return ((LegacyS3ProgressListener)generalProgressListener).unwrap();
        } else {
             return null;
        }
    }

    
Sets the optional progress listener for receiving updates about object upload status, and returns this updated object so that additional method calls can be chained together.

Deprecated:
use com.amazonaws.AmazonWebServiceRequest.withGeneralProgressListener(com.amazonaws.event.ProgressListener) instead.
Parameters:
progressListener The legacy progress listener that is used exclusively for Amazon S3 client.
Returns:
This updated PutObjectRequest object.
    @Deprecated
    public <T extends AbstractPutObjectRequest> T withProgressListener(
            com.amazonaws.services.s3.model.ProgressListener progressListener) {
        setProgressListener(progressListener);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }

    
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 PutObjectRequest
            SSEAwsKeyManagementParams sseAwsKeyManagementParams) {
        setSSEAwsKeyManagementParams(sseAwsKeyManagementParams);
        @SuppressWarnings("unchecked") T t = (T)this;
        return t;
    }
    @Override
    public abstract AbstractPutObjectRequest clone();
    protected final <T extends AbstractPutObjectRequest> T copyPutObjectBaseTo(
            T target) {
        copyBaseTo(target);
        final ObjectMetadata metadata = getMetadata();
        return target.withAccessControlList(getAccessControlList())
            .withCannedAcl(getCannedAcl())
            .withInputStream(getInputStream())
            .withMetadata(metadata == null ? null : metadata.clone())
            .withRedirectLocation(getRedirectLocation())
            .withStorageClass(getStorageClass())
            .withSSECustomerKey(getSSECustomerKey())
            ;
    }
New to GrepCode? Check out our FAQ X