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 {@link Permission#Write} permission to the bucket to upload an object.
@see PutObjectRequest#PutObjectRequest(String,String,File)
@see PutObjectRequest#PutObjectRequest(String,String,InputStream,ObjectMetadata)