AWS SDK for .NET Documentation
GetObjectResponse Class
AmazonAmazon.S3.ModelGetObjectResponse Did this page help you?   Yes   No    Tell us about it...
The GetObjectResponse contains any header or metadata returned by S3. GetObjectResponse's contain resources that need to be disposed. The recommended way for handling GetObjectResponse objects is wrapping them in using clauses, like so:
CopyC#
using (GetObjectResponse response = s3Client.GetObject(request))
{
    ...
}
This will ensure that any network resources, file streams and web headers have been returned back to the system for future use.
Declaration Syntax
C#
public class GetObjectResponse : S3Response
Members
All MembersConstructorsMethodsPropertiesEvents



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

AmazonId2
Gets and sets the AmazonId2 property. This property corresponds to the x-amz-id-2 header in the HTTP response from the Amazon S3 service. The value of this header is used for internal troubleshooting purposes.
(Inherited from S3Response.)
BucketName
Gets and sets the BucketName property.

ContentLength
Gets and sets the ContentLength property.

ContentType
Gets and sets the ContentType property.

Dispose()()()()
Disposes of all managed and unmanaged resources.
(Inherited from S3Response.)
Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
ETag
Gets and sets the ETag 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.

GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()()
Gets the type of the current instance.
(Inherited from Object.)
Headers
Gets and sets the Headers property.
(Overrides S3Response.Headers.)
Key
Gets and sets the Key property.

Metadata
Gets and sets the Metadata property.
(Inherited from S3Response.)
RequestId
Gets and sets the RequestId property.
(Inherited from S3Response.)
ResponseStream
Gets and sets the ResponseStream property. This property only has a valid value for GetObjectResponses. In order to use this stream without leaking the underlying resource, please wrap access to the stream within a using block.
CopyC#
(Inherited from S3Response.)
ResponseXml
Gets and sets the ResponseXml property. This is the original xml response received from S3
(Inherited from S3Response.)
RestoreExpiration
Gets and sets the RestoreExpiration property. RestoreExpiration will be set for objects that have been restored from Amazon Glacier. It indiciates for those objects how long the restored object will exist.

RestoreInProgress
Gets and sets the RestoreInProgress Will be true when the object is in the process of being restored from Amazon Glacier.

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

ServerSideEncryptionMethod
Gets and sets the ServerSideEncryptionMethod property. Specifies the encryption used on the server to store the content. Default is None.

StatusCode
Gets the HTTP Status code from the service response.
(Inherited from S3Response.)
ToString()()()()
String Representation of this object. Overrides Object.ToString()
(Inherited from S3Response.)
VersionId
Gets and sets the VersionId property. This is the version-id of the S3 object

WebsiteRedirectLocation
Gets and sets the WebsiteRedirectLocation property. 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.

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

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

WriteResponseStreamToFile(String)
Writes the content of the ResponseStream a file indicated by the filePath argument.

WriteResponseStreamToFile(String, Boolean)
Writes the content of the ResponseStream a file indicated by the filePath argument.

Examples

This example shows how to get an object.

CopyGetObject 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);
    }
}
Inheritance Hierarchy
Object
S3Response
 GetObjectResponse

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