AWS SDK Version 2 for .NET
API Reference

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.

.NET Framework 4.5
Retrieves objects from Amazon S3.

Namespace: Amazon.S3
Assembly: AWSSDK.dll
Version: (assembly version)


public abstract GetObjectResponse GetObject(
         GetObjectRequest request


Type: Amazon.S3.Model.GetObjectRequest

Container for the necessary parameters to execute the GetObject service method.

Return Value
Type: Amazon.S3.Model.GetObjectResponse
The response from the GetObject service method, as returned by S3.


This example shows how to get an object.

GetObject sample

// Create a client
AmazonS3Client client = new AmazonS3Client();

// Create a GetObject request
GetObjectRequest request = new GetObjectRequest
    BucketName = "SampleBucket",
    Key = "Item1"

// Issue request and remember to dispose of the response
using (GetObjectResponse response = client.GetObject(request))
    using (StreamReader reader = new StreamReader(response.ResponseStream))
        string contents = reader.ReadToEnd();
        Console.WriteLine("Object - " + response.Key);
        Console.WriteLine(" Version Id - " + response.VersionId);
        Console.WriteLine(" Contents - " + contents);


Version Information

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