AWS SDK for .NET Documentation
PutObjectRequest Class
AmazonAmazon.S3.ModelPutObjectRequest Did this page help you?   Yes   No    Tell us about it...
The parameters to add or update an object in a bucket.
Declaration Syntax
C#
public class PutObjectRequest : S3PutWithACLRequest
Members
All MembersConstructorsMethodsPropertiesEvents



IconMemberDescription
PutObjectRequest()()()()
Initializes a new instance of the PutObjectRequest class

AddHeader(String, String)
Adds the header to the collection of headers for the request.
(Inherited from S3Request.)
AddHeaders(NameValueCollection)
Adds all of the specified key/value pairs into the request headers collection.
(Inherited from S3Request.)
AutoCloseStream
If this value is set to true then the stream used with this request will be closed when all the content is read from the stream. Default: true.

BucketName
The name of the bucket to contain the object.

CannedACL
A canned access control list (CACL) to apply to the object. Please refer to S3CannedACL for information on S3 Canned ACLs.

ContentBody
Text content to be uploaded. Use this property if you want to upload plaintext to S3. The content type will be set to 'text/plain'.

ContentType
A standard MIME type describing the format of the object data.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
FilePath
The full path and name to a file to be uploaded. If this is set the request will upload the specified file to S3.

GenerateMD5Digest
If set, an MD5 digest is automatically computed for the content being uploaded.

GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()()
Gets the type of the current instance.
(Inherited from Object.)
Grants
Gets the access control lists (ACLs) for this request. Please refer to S3Grant for information on S3 Grants.
(Inherited from S3PutWithACLRequest.)
InputStream
Input stream for the request; content for the request will be read from the stream.
(Inherited from S3Request.)
Key
The key of the object to be created (or updated).

MD5Digest
An MD5 digest for the content.

PutObjectProgressEvent
The event for Put Object progress notifications. All subscribers will be notified when a new progress event is raised.

ReadWriteTimeout
Overrides the default HttpWebRequest ReadWriteTimeout value.
(Inherited from S3Request.)
RemoveCannedACL()()()()
Resets any previous CannedACL set in this object.

RemoveMetaData(String)
Removes a key from the Metadata list if it was added previously to this object.

ServerSideEncryptionCustomerMethod
The Server-side encryption algorithm to be used with the customer provided key.

ServerSideEncryptionCustomerProvidedKey
The base64-encoded encryption key for Amazon S3 to use to encrypt the object

Using the encryption key you provide as part of your request Amazon S3 manages both the encryption, as it writes to disks, and decryption, when you access your objects. Therefore, you don't need to maintain any data encryption code. The only thing you do is manage the encryption keys you provide.

When you retrieve an object, you must provide the same encryption key as part of your request. Amazon S3 first verifies the encryption key you provided matches, and then decrypts the object before returning the object data to you.

Important: Amazon S3 does not store the encryption key you provide.


ServerSideEncryptionMethod
Specifies the encryption used on the server to store the content.

StorageClass
StorageClass value to apply to the S3 object. Default: S3StorageClass.Standard.

Timeout
Overrides the default HttpWebRequest timeout value.
(Inherited from S3Request.)
ToString()()()() (Inherited from S3Request.)
WebsiteRedirectLocation
If this is set then when a GET request is made from the S3 website endpoint a 301 HTTP status code will be returned indicating a redirect with this value as the redirect location.

WithAutoCloseStream(Boolean) Obsolete.
If this value is set to true then the stream used with this request will be closed when all the content is read from the stream. Default: true.

WithBucketName(String) Obsolete.
Sets the name of the bucket to contain the object.

WithCannedACL(S3CannedACL) Obsolete.
A canned access control list (CACL) to apply to the object. Please refer to S3CannedACL for information on S3 Canned ACLs.

WithContentBody(String) Obsolete.
Text content to be uploaded. Use this property if you want to upload plaintext to S3. The content type will be set to 'text/plain'.

WithContentType(String) Obsolete.
Sets a standard MIME type describing the format of the object data.

WithFilePath(String) Obsolete.
Sets the full path and name to a file to be uploaded. If this is set the request will upload the specified file to S3.

WithGenerateChecksum(Boolean) Obsolete.
If set, an MD5 digest is automatically computed for the content being uploaded.

WithGrants(array<S3Grant>[]()[][]) Obsolete.
Adds custom access control lists (ACLs) to the object. Please refer to S3Grant for information on S3 Grants.

WithInputStream(Stream) Obsolete.
Sets an input stream for the request; content for the request will be read from the stream.
(Inherited from S3Request.)
WithKey(String) Obsolete.
Sets key of the object to be created (or updated).

WithMD5Digest(String) Obsolete.
Sets an MD5 digest for the content.

WithMetaData(String, String)
Adds a key/value metadata pair to the object when uploaded.

WithMetaData(NameValueCollection)
Adds a set of key-value metadata pairs to the object when uploaded.

WithReadWriteTimeout(Int32) Obsolete.
Sets a custom ReadWriteTimeout property (in milliseconds).

WithServerSideEncryptionMethod(ServerSideEncryptionMethod) Obsolete.
Specifies the encryption used on the server to store the content.

WithStorageClass(S3StorageClass) Obsolete.
Sets a StorageClass for the S3 object. Default: S3StorageClass.Standard.

WithSubscriber(EventHandler<(Of <<'(PutObjectProgressArgs>)>>)) Obsolete.
The "handler" will be notified every time a put object progress event is raised.

WithTimeout(Int32) Obsolete.
Sets a custom Timeout property (in milliseconds).

WithWebsiteRedirectLocation(String) Obsolete.
If this is set then when a GET request is made from the S3 website endpoint a 301 HTTP status code will be returned indicating a redirect with this value as the redirect location.

Examples

This following examples show multiple ways of creating an object.

This example shows how to put an object, with its content being passed along as a string.

CopyPutObject sample 1
// Create a client
AmazonS3Client client = new AmazonS3Client();

// Create a PutObject request
PutObjectRequest request = new PutObjectRequest
{
    BucketName = "SampleBucket",
    Key = "Item1",
    ContentBody = "This is sample content..."
};

// Put object
PutObjectResponse response = client.PutObject(request);

This example shows how to put an object, setting its content to be a file.

CopyPutObject sample 2
// Create a client
AmazonS3Client client = new AmazonS3Client();

// Create a PutObject request
PutObjectRequest request = new PutObjectRequest
{
    BucketName = "SampleBucket",
    Key = "Item1",
    FilePath = "contents.txt"
};

// Put object
PutObjectResponse response = client.PutObject(request);

This example shows how to put an object using a stream.

CopyPutObject sample 3
// Create a client
AmazonS3Client client = new AmazonS3Client();

// Create a PutObject request
PutObjectRequest request = new PutObjectRequest
{
    BucketName = "SampleBucket",
    Key = "Item1",
};
using (FileStream stream = new FileStream("contents.txt", FileMode.Open))
{
    request.InputStream = stream;

    // Put object
    PutObjectResponse response = client.PutObject(request);
}
Inheritance Hierarchy

Assembly: AWSSDK (Module: AWSSDK) Version: 1.5.60.0 (1.5.60.0)