GetObjectResponse Class

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

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AmazonWebServiceResponse
    Amazon.S3.Model.StreamResponse
      Amazon.S3.Model.GetObjectResponse

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

Syntax

C#
public class GetObjectResponse : StreamResponse
         IDisposable

The GetObjectResponse type exposes the following members

Constructors

  Name Description
Public Method GetObjectResponse()

Properties

  Name Description
Public Property AcceptRanges
Public Property BucketName Gets and sets the BucketName property.
Public Property ContentLength Returns the content length of the HTTP response.
Public Property DeleteMarker Specifies whether the object retrieved was (true) or was not (false) a Delete Marker. If false, this response header does not appear in the response.
Public Property ETag An ETag is an opaque identifier assigned by a web server to a specific version of a resource found at a URL
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 Expires The date and time at which the object is no longer cacheable.
Public Property Headers The collection of headers for the request.
Public Property HttpStatusCode Returns the status code of the HTTP response.
Public Property Key Gets and sets the Key property.
Public Property LastModified Last modified date of the object
Public Property MetaData The collection of meta data for the request.
Public Property MissingMeta This is set to the number of metadata entries not returned in x-amz-meta headers. This can happen if you create metadata using an API like SOAP that supports more flexible metadata than the REST API. For example, using SOAP, you can create metadata whose values are not legal HTTP headers.
Public Property ResponseMetadata Contains additional information about the request, such as the Request Id.
Public Property ResponseStream An open stream read from to get the data from S3. In order to use this stream without leaking the underlying resource, please wrap access to the stream within a using block.
Public Property 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.
Public Property RestoreInProgress Gets and sets the RestoreInProgress Will be true when the object is in the process of being restored from Amazon Glacier.
Public Property ServerSideEncryptionMethod The Server-side encryption algorithm used when storing this object in S3.
Public Property VersionId Version of the object.
Public Property WebsiteRedirectLocation If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata.

Methods

  Name Description
Public Method Dispose() Disposes of all managed and unmanaged resources.
Public Method WriteResponseStreamToFile(string) Writes the content of the ResponseStream a file indicated by the filePath argument.
Public Method WriteResponseStreamToFile(string, bool) Writes the content of the ResponseStream a file indicated by the filePath argument.

Examples

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

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

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