com.amazonaws.services.s3.model

## クラス PutObjectRequest

- java.lang.Object
- - com.amazonaws.AmazonWebServiceRequest
  - - com.amazonaws.services.s3.model.PutObjectRequest

-     public class PutObjectRequest
      extends AmazonWebServiceRequest

  Uploads a new object to the specified Amazon S3 bucket. The PutObjectRequest optionally uploads object metadata and applies a canned access control policy to the new object.

  Amazon S3 never stores partial objects; if during this call an exception wasn't thrown, the entire object was stored.

  Depending on whether a file or input stream is being uploaded, this request has slightly different behavior.

  When uploading a file:

  - The client automatically computes a checksum of the file. Amazon S3 uses checksums to validate the data in each file.
  - Using the file extension, Amazon S3 attempts to determine the correct content type and content disposition to use for the object.

  When uploading directly from an input stream, content length must be specified before data can be uploaded to Amazon S3. If not provided, the library will have to buffer the contents of the input stream in order to calculate it. Amazon S3 explicitly requires that the content length be sent in the request headers before any of the data is sent.

Amazon S3 is a distributed system. If Amazon S3 receives multiple write requests for the same object nearly simultaneously, all of the objects might be stored. However, only one object will obtain the key.

Note: Amazon S3 does not provide object locking; if this is needed, make sure to build it into the application layer.

If the caller specifies a location constraint when creating a bucket, all objects added to the bucket are stored in the same region as the bucket. For example, if specifying a Europe (EU) region constraint for a bucket, all of that bucket's objects are stored in the EU region.

The specified bucket must already exist and the caller must have `Permission.Write` permission to the bucket to upload an object.

関連項目:
  `PutObjectRequest(String, String, File)`, `PutObjectRequest(String, String, InputStream, ObjectMetadata)`

- - ### コンストラクタの概要

    コンストラクタ
    コンストラクタと説明
    `PutObjectRequest(java.lang.String bucketName, java.lang.String key, java.io.File file)` Constructs a new `PutObjectRequest` object to upload a file to the specified bucket and key.
    `PutObjectRequest(java.lang.String bucketName, java.lang.String key, java.io.InputStream input, ObjectMetadata metadata)` Constructs a new `PutObjectRequest` object to upload a stream of data to the specified bucket and key.
    `PutObjectRequest(java.lang.String bucketName, java.lang.String key, java.lang.String redirectLocation)` Constructs a new `PutObjectRequest` object with redirect location.

  - ### メソッドの概要

    メソッド
    修飾子とタイプ | メソッドと説明
    --- | ---
    `AccessControlList` | `getAccessControlList()` Returns the optional access control list for the new object.
    `java.lang.String` | `getBucketName()` Gets the name of the existing bucket where this request will upload a new object to.
    `CannedAccessControlList` | `getCannedAcl()` Gets the optional pre-configured access control policy to use for the new object.
    `java.io.File` | `getFile()` Gets the path and name of the file containing the data to be uploaded to Amazon S3.
    `java.io.InputStream` | `getInputStream()` Gets the input stream containing the data to be uploaded to Amazon S3.
    `java.lang.String` | `getKey()` Gets the key under which to store the new object.
    `ObjectMetadata` | `getMetadata()` Gets the optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.).
    `ProgressListener` | `getProgressListener()` Returns the optional progress listener for receiving updates about object upload status.
    `java.lang.String` | `getRedirectLocation()` Gets the optional redirect location for the new object.
    `java.lang.String` | `getStorageClass()` Gets the optional Amazon S3 storage class to use when storing the new object.
    `void` | `setAccessControlList(AccessControlList accessControlList)` Sets the optional access control list for the new object.
    `void` | `setBucketName(java.lang.String bucketName)` Sets the name of an existing bucket where this request will upload a new object to.
    `void` | `setCannedAcl(CannedAccessControlList cannedAcl)` Sets the optional pre-configured access control policy to use for the new object.
    `void` | `setFile(java.io.File file)` Sets the path and name of the file containing the data to be uploaded to Amazon S3.
    `void` | `setInputStream(java.io.InputStream inputStream)` Sets the input stream containing the data to be uploaded to Amazon S3.
    `void` | `setKey(java.lang.String key)` Sets the key under which to store the new object.
    `void` | `setMetadata(ObjectMetadata 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.).
    `void` | `setProgressListener(ProgressListener progressListener)` Sets the optional progress listener for receiving updates for object upload status.
    `void` | `setRedirectLocation(java.lang.String redirectLocation)` Sets the optional redirect location for the new object.
    `void` | `setStorageClass(StorageClass storageClass)` Sets the optional Amazon S3 storage class to use when storing the new object.
    `void` | `setStorageClass(java.lang.String storageClass)` Sets the optional Amazon S3 storage class to use when storing the new object.
    `PutObjectRequest` | `withAccessControlList(AccessControlList accessControlList)` Sets the optional access control list for the new object.
    `PutObjectRequest` | `withBucketName(java.lang.String bucketName)` Sets the name of the bucket where this request will upload a new object to.
    `PutObjectRequest` | `withCannedAcl(CannedAccessControlList cannedAcl)` Sets the optional pre-configured access control policy to use for the new object.
    `PutObjectRequest` | `withFile(java.io.File file)` Sets the file containing the data to be uploaded to Amazon S3.
    `PutObjectRequest` | `withInputStream(java.io.InputStream inputStream)` Sets the input stream containing the data to be uploaded to Amazon S3.
    `PutObjectRequest` | `withKey(java.lang.String key)` Sets the key under which to store the new object.
    `PutObjectRequest` | `withMetadata(ObjectMetadata 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.).
    `PutObjectRequest` | `withProgressListener(ProgressListener progressListener)` 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.
    `PutObjectRequest` | `withRedirectLocation(java.lang.String redirectLocation)` Sets the optional redirect location for the new object.Returns this `PutObjectRequest`, enabling additional method calls to be chained together.
    `PutObjectRequest` | `withStorageClass(StorageClass storageClass)` Sets the optional Amazon S3 storage class to use when storing the new object.
    `PutObjectRequest` | `withStorageClass(java.lang.String storageClass)` Sets the optional Amazon S3 storage class to use when storing the new object.

    - ### クラスから継承されたメソッド com.amazonaws.AmazonWebServiceRequest

      `copyPrivateRequestParameters, getRequestClientOptions, getRequestCredentials, setRequestCredentials`

    - ### クラスから継承されたメソッド java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### コンストラクタの詳細

    - #### PutObjectRequest

          public PutObjectRequest(java.lang.String bucketName,
                          java.lang.String key,
                          java.io.File file)

      Constructs a new `PutObjectRequest` 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.
      パラメータ:
        `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.
      関連項目:
        `PutObjectRequest(String, String, InputStream, ObjectMetadata)`

    - #### PutObjectRequest

          public PutObjectRequest(java.lang.String bucketName,
                          java.lang.String key,
                          java.lang.String redirectLocation)

      Constructs a new `PutObjectRequest` object with redirect location. After constructing the request, users may optionally specify object metadata or a canned ACL as well.
      パラメータ:
        `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.
      関連項目:
        `PutObjectRequest(String, String, InputStream, ObjectMetadata)`, `PutObjectRequest(String, String, File)`

    - #### PutObjectRequest

          public PutObjectRequest(java.lang.String bucketName,
                          java.lang.String key,
                          java.io.InputStream input,
                          ObjectMetadata metadata)

      Constructs a new `PutObjectRequest` 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.

      パラメータ:
        `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.
      関連項目:
        `PutObjectRequest(String, String, File)`, `PutObjectRequest(String bucketName, String key, String redirectLocation)`

  - ### メソッドの詳細

    - #### getBucketName

          public java.lang.String getBucketName()

      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.
      戻り値:
        The name of an existing bucket where this request will upload a new object to.
      関連項目:
        `setBucketName(String)`, `withBucketName(String)`

    - #### setBucketName

          public void setBucketName(java.lang.String bucketName)

      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.
      パラメータ:
        `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.
      関連項目:
        `getBucketName()`, `withBucketName(String)`

    - #### withBucketName

          public PutObjectRequest withBucketName(java.lang.String 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.

      パラメータ:
        `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.
      戻り値:
        This `PutObjectRequest`, enabling additional method calls to be chained together.
      関連項目:
        `getBucketName()`, `setBucketName(String)`

    - #### getKey

          public java.lang.String getKey()

      Gets the key under which to store the new object.
      戻り値:
        The key under which to store the new object.
      関連項目:
        `setKey(String)`, `withKey(String)`

    - #### setKey

          public void setKey(java.lang.String key)

      Sets the key under which to store the new object.
      パラメータ:
        `key` - The key under which to store the new object.
      関連項目:
        `getKey()`, `withKey(String)`

    - #### withKey

          public PutObjectRequest withKey(java.lang.String key)

      Sets the key under which to store the new object. Returns this object, enabling additional method calls to be chained together.
      パラメータ:
        `key` - The key under which to store the new object.
      戻り値:
        This `PutObjectRequest`, enabling additional method calls to be chained together.
      関連項目:
        `getKey()`, `setKey(String)`

    - #### getStorageClass

          public java.lang.String getStorageClass()

      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.

      戻り値:
        The Amazon S3 storage class to use when storing the newly copied object.
      関連項目:
        `setStorageClass(String)`, `setStorageClass(StorageClass)`, `withStorageClass(StorageClass)`, `withStorageClass(String)`

    - #### setStorageClass

          public void setStorageClass(java.lang.String storageClass)

      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.

      パラメータ:
        `storageClass` - The storage class to use when storing the new object.
      関連項目:
        `getStorageClass()`, `PutObjectRequest#setStorageClass(StorageClass`, `withStorageClass(StorageClass)`, `withStorageClass(String)`

    - #### withStorageClass

          public PutObjectRequest withStorageClass(java.lang.String storageClass)

      Sets the optional Amazon S3 storage class to use when storing the new object. Returns this `PutObjectRequest`, 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.

      パラメータ:
        `storageClass` - The storage class to use when storing the new object.
      戻り値:
        This `PutObjectRequest`, enabling additional method calls to be chained together.
      関連項目:
        `getStorageClass()`, `setStorageClass(StorageClass)`, `setStorageClass(String)`, `withStorageClass(StorageClass)`

    - #### setStorageClass

          public void setStorageClass(StorageClass storageClass)

      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.

      パラメータ:
        `storageClass` - The storage class to use when storing the new object.
      関連項目:
        `getStorageClass()`, `setStorageClass(String)`

    - #### withStorageClass

          public PutObjectRequest withStorageClass(StorageClass storageClass)

      Sets the optional Amazon S3 storage class to use when storing the new object. Returns this `PutObjectRequest`, 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.

      パラメータ:
        `storageClass` - The storage class to use when storing the new object.
      戻り値:
        This `PutObjectRequest`, enabling additional method calls to be chained together.
      関連項目:
        `getStorageClass()`, `setStorageClass(StorageClass)`, `setStorageClass(String)`, `withStorageClass(String)`

    - #### getFile

          public java.io.File getFile()

      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.
      戻り値:
        The path and name of the file containing the data to be uploaded to Amazon S3.
      関連項目:
        `setFile(File)`, `withFile(File)`, `setInputStream(InputStream)`, `withInputStream(InputStream)`

    - #### setFile

          public void setFile(java.io.File file)

      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.
      パラメータ:
        `file` - The path and name of the file containing the data to be uploaded to Amazon S3.
      関連項目:
        `getFile()`, `withFile(File)`, `getInputStream()`, `withInputStream(InputStream)`

    - #### withFile

          public PutObjectRequest withFile(java.io.File file)

      Sets the file containing the data to be uploaded to Amazon S3. Returns this `PutObjectRequest`, 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.

      パラメータ:
        `file` - The file containing the data to be uploaded to Amazon S3.
      戻り値:
        This `PutObjectRequest`, enabling additional method calls to be chained together.
      関連項目:
        `getFile()`, `setFile(File)`, `getInputStream()`, `setInputStream(InputStream)`

    - #### getMetadata

          public ObjectMetadata getMetadata()

      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.

      戻り値:
        The optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.).
      関連項目:
        `setMetadata(ObjectMetadata)`, `withMetadata(ObjectMetadata)`

    - #### setMetadata

          public void setMetadata(ObjectMetadata 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.).

      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.

      パラメータ:
        `metadata` - The optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.).
      関連項目:
        `getMetadata()`, `withMetadata(ObjectMetadata)`

    - #### withMetadata

          public PutObjectRequest withMetadata(ObjectMetadata 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 `PutObjectRequest`, 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.

      パラメータ:
        `metadata` - The optional metadata instructing Amazon S3 how to handle the uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.).
      戻り値:
        This `PutObjectRequest`, enabling additional method calls to be chained together.
      関連項目:
        `getMetadata()`, `setMetadata(ObjectMetadata)`

    - #### getCannedAcl

          public CannedAccessControlList getCannedAcl()

      Gets the optional pre-configured access control policy to use for the new object.
      戻り値:
        The optional pre-configured access control policy to use for the new object.
      関連項目:
        `setCannedAcl(CannedAccessControlList)`, `withCannedAcl(CannedAccessControlList)`

    - #### setCannedAcl

          public void setCannedAcl(CannedAccessControlList cannedAcl)

      Sets the optional pre-configured access control policy to use for the new object.
      パラメータ:
        `cannedAcl` - The optional pre-configured access control policy to use for the new object.
      関連項目:
        `getCannedAcl()`, `withCannedAcl(CannedAccessControlList)`

    - #### withCannedAcl

          public PutObjectRequest withCannedAcl(CannedAccessControlList cannedAcl)

      Sets the optional pre-configured access control policy to use for the new object. Returns this `PutObjectRequest`, enabling additional method calls to be chained together.
      パラメータ:
        `cannedAcl` - The optional pre-configured access control policy to use for the new object.
      戻り値:
        This `PutObjectRequest`, enabling additional method calls to be chained together.
      関連項目:
        `getCannedAcl()`, `setCannedAcl(CannedAccessControlList)`

    - #### getAccessControlList

          public AccessControlList getAccessControlList()

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

    - #### setAccessControlList

          public void setAccessControlList(AccessControlList accessControlList)

      Sets the optional access control list for the new object. If specified, cannedAcl will be ignored.
      パラメータ:
        `accessControlList` - The access control list for the new object.

    - #### withAccessControlList

          public PutObjectRequest withAccessControlList(AccessControlList accessControlList)

      Sets the optional access control list for the new object. If specified, cannedAcl will be ignored. Returns this `PutObjectRequest`, enabling additional method calls to be chained together.
      パラメータ:
        `accessControlList` - The access control list for the new object.

    - #### getInputStream

          public java.io.InputStream getInputStream()

      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.
      戻り値:
        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.
      関連項目:
        `setInputStream(InputStream)`, `withInputStream(InputStream)`, `setFile(File)`, `withFile(File)`

    - #### setInputStream

          public void setInputStream(java.io.InputStream inputStream)

      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.
      パラメータ:
        `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.
      関連項目:
        `getInputStream()`, `withInputStream(InputStream)`, `getFile()`, `withFile(File)`

    - #### withInputStream

          public PutObjectRequest withInputStream(java.io.InputStream inputStream)

      Sets the input stream containing the data to be uploaded to Amazon S3. Returns this `PutObjectRequest`, 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.

      パラメータ:
        `inputStream` - The InputStream containing the data to be uploaded to Amazon S3.
      戻り値:
        This PutObjectRequest, so that additional method calls can be chained together.
      関連項目:
        `getInputStream()`, `setInputStream(InputStream)`, `getFile()`, `setFile(File)`

    - #### setRedirectLocation

          public void setRedirectLocation(java.lang.String redirectLocation)

      Sets the optional redirect location for the new object.
      パラメータ:
        `redirectLocation` - The redirect location for the new object.

    - #### getRedirectLocation

          public java.lang.String getRedirectLocation()

      Gets the optional redirect location for the new object.

    - #### withRedirectLocation

          public PutObjectRequest withRedirectLocation(java.lang.String redirectLocation)

      Sets the optional redirect location for the new object.Returns this `PutObjectRequest`, enabling additional method calls to be chained together.
      パラメータ:
        `redirectLocation` - The redirect location for the new object.

    - #### setProgressListener

          public void setProgressListener(ProgressListener progressListener)

      Sets the optional progress listener for receiving updates for object upload status.
      パラメータ:
        `progressListener` - The new progress listener.

    - #### getProgressListener

          public ProgressListener getProgressListener()

      Returns the optional progress listener for receiving updates about object upload status.
      戻り値:
        the optional progress listener for receiving updates about object upload status.

    - #### withProgressListener

          public PutObjectRequest withProgressListener(ProgressListener progressListener)

      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.
      パラメータ:
        `progressListener` - The new progress listener.
      戻り値:
        This updated PutObjectRequest object.