PutObjectResponse Class

.NET Framework 4.5
 
 
 
Did this page help you?  Yes  No   Tell us about it...
Returns information about the PutObject response and response metadata.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceResponse
    Amazon.S3.Model.PutObjectResponse

Namespace: Amazon.S3.Model
Assembly: AWSSDK.dll
Version: 2.0.0.3

Syntax

C#
public class PutObjectResponse : AmazonWebServiceResponse

The PutObjectResponse type exposes the following members

Constructors

  Name Description
Public Method PutObjectResponse()

Properties

  Name Description
Public Property ContentLength Returns the content length of the HTTP response.
Public Property ETag Entity tag for the uploaded object.
Public Property 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.
Public Property HttpStatusCode Returns the status code of the HTTP response.
Public Property ResponseMetadata Contains additional information about the request, such as the Request Id.
Public Property ServerSideEncryptionMethod The Server-side encryption algorithm used when storing this object in S3.
Public Property VersionId Version of the object.

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.

PutObject 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.

PutObject 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.

PutObject 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);
}

                

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

.NET for Windows Store apps:
Supported in: Windows 8

.NET for Windows Phone:
Supported in: Window Phone 8