本文整理汇总了C#中AmazonS3.GetObject方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonS3.GetObject方法的具体用法?C# AmazonS3.GetObject怎么用?C# AmazonS3.GetObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AmazonS3
的用法示例。
在下文中一共展示了AmazonS3.GetObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResizeImageAndUpload
public static void ResizeImageAndUpload(AmazonS3 anAmazonS3Client, string aBucketName, string aCurrentPhotoName, string aNewImageName, int aSize)
{
GetObjectRequest myGetRequest = new GetObjectRequest().WithBucketName(aBucketName).WithKey(aCurrentPhotoName);
GetObjectResponse myResponse = anAmazonS3Client.GetObject(myGetRequest);
Stream myStream = myResponse.ResponseStream;
ResizeAndUpload(myStream, anAmazonS3Client, aBucketName, aNewImageName, aSize);
}
示例2: GetObject
private static void GetObject(AmazonS3 s3Client, string bucket, string key)
{
var getObjectRequest = new GetObjectRequest().WithBucketName(bucket).WithKey(key);
using (var getObjectResponse = s3Client.GetObject(getObjectRequest))
{
var memoryStream = new MemoryStream();
getObjectResponse.ResponseStream.CopyTo(memoryStream);
var content = Encoding.Default.GetString(memoryStream.ToArray());
Console.WriteLine(content);
}
}
示例3: RestoreFromAmazon
private void RestoreFromAmazon(AmazonS3 client)
{
try
{
GetObjectRequest request = new GetObjectRequest()
.WithBucketName(this.BucketName)
.WithKey(FileLocations.CONFIG_FILENAME);
using (GetObjectResponse response = client.GetObject(request))
{
response.WriteResponseStreamToFile(settings.FileLocations.Configuration);
settings.ForceReload();
}
this.ErrorLabel.ForeColor = Color.Black;
this.ErrorLabel.Text = "The restore was a success!";
}
catch (Exception exc)
{
this.ErrorLabel.ForeColor = Color.Red;
this.ErrorLabel.Text = exc.Message;
}
}
示例4: GetFile
public static System.IO.MemoryStream GetFile(AmazonS3 s3Client, string filekey)
{
using (s3Client)
{
S3_KEY = filekey;
System.IO.MemoryStream file = new System.IO.MemoryStream();
try
{
GetObjectResponse r = s3Client.GetObject(new GetObjectRequest()
{
BucketName = BUCKET_NAME,
Key = S3_KEY
});
try
{
long transferred = 0L;
System.IO.BufferedStream stream2 = new System.IO.BufferedStream(r.ResponseStream);
byte[] buffer = new byte[0x2000];
int count = 0;
while ((count = stream2.Read(buffer, 0, buffer.Length)) > 0)
{
file.Write(buffer, 0, count);
}
}
finally
{
}
return file;
}
catch (AmazonS3Exception)
{
//Show exception
}
}
return null;
}
示例5: getLastSession
private void getLastSession()
{
string cookieName;
string cookieValue;
using (client = Amazon.AWSClientFactory.CreateAmazonS3Client("AKIAJ47VSG7WMA62WLCA", "3tqlHujlftpk6j/z5OtDw2eg9N2FJtz1RwL8bEa3"))
{
GetObjectRequest txtRequest = new GetObjectRequest();
txtRequest.WithBucketName("intelrecruiter")
.WithKey(nsbeCookieValueKey);
var response = client.GetObject(txtRequest);
StreamReader reader = new StreamReader(response.ResponseStream);
cookieValue = reader.ReadToEnd();
response.Dispose();
txtRequest = new GetObjectRequest();
txtRequest.WithBucketName("intelrecruiter")
.WithKey(nsbeCookieNameKey);
response = client.GetObject(txtRequest);
reader = new StreamReader(response.ResponseStream);
cookieName = reader.ReadToEnd();
response.Dispose();
}
nsbeCookie = new Cookie(cookieName, cookieValue, "/");
}