AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Namespace: Amazon.S3.Model
Assembly: AWSSDK.dll
Version: (assembly version)
public class PutObjectResponse : AmazonWebServiceResponse
The PutObjectResponse type exposes the following members
| Name | Description | |
|---|---|---|
|
PutObjectResponse() |
| Name | Type | Description | |
|---|---|---|---|
|
ContentLength | System.Int64 | Inherited from Amazon.Runtime.AmazonWebServiceResponse. |
|
ETag | System.String | Entity tag for the uploaded object. |
|
Expiration | Amazon.S3.Model.Expiration | Gets and sets the Expiration property. Specifies the expiration date for the object and the rule governing the expiration. Is null if expiration is not applicable. |
|
HttpStatusCode | System.Net.HttpStatusCode | Inherited from Amazon.Runtime.AmazonWebServiceResponse. |
|
ResponseMetadata | Amazon.Runtime.ResponseMetadata | Inherited from Amazon.Runtime.AmazonWebServiceResponse. |
|
ServerSideEncryptionKeyManagementServiceKeyId | System.String | The id of the AWS Key Management Service key that Amazon S3 uses to encrypt and decrypt the object. |
|
ServerSideEncryptionMethod | Amazon.S3.ServerSideEncryptionMethod | The Server-side encryption algorithm used when storing this object in S3. |
|
VersionId | System.String | Version of the object. |
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.
// 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.
// 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.
// 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);
}
.NET Framework:
Supported in: 4.5, 4.0, 3.5
.NET for Windows Store apps:
Supported in: Windows 8.1, Windows 8
.NET for Windows Phone:
Supported in: Windows Phone 8.1, Windows Phone 8