User guide
using (GetObjectResponse response = client.GetObject(request)) {
using (Stream responseStream = response.ResponseStream) {
using (StreamReader reader = new StreamReader(responseStream)) {
responseBody = reader.ReadToEnd();
}
}
}
}
FileStream s = new FileStream( "s3Object.txt", FileMode.Create );
StreamWriter writer = new StreamWriter( s );
writer.WriteLine( responseBody );
}
catch (AmazonS3Exception s3Exception) {
Console.WriteLine(s3Exception.Message, s3Exception.InnerException);
}
} // main
} // class
} // namespace
Transfer the Compiled Program to Your Amazon EC2 Instance
To transfer the program to your Amazon EC2 instance, connect to your Amazon EC2 instance using
Remote Desktop. In the Instances view in the AWS Management Console, either click Instance Actions
or right-click your Amazon EC2 instance and select Connect.
You need to retrieve the administrator's password for your Amazon EC2 instance in order to connect. To
retrieve the password, you need to specify the private key file for the key pair. When you create a key
pair, you have an opportunity to download the private key to your local computer.This file ends in a PEM
extension.
You can invoke the Remote Desktop client from the Start menu on your computer or you can download
a shortcut from the Connect dialog box in the AWS Management Console.
Version v2.0.0
37
AWS SDK for .NET Developer Guide
Walkthrough: Using IAM Roles to Retrieve an Amazon
S3 Object from an Amazon EC2 Instance