Reputation: 243
I can download a file from the Amazon S3 Storage with below code,
var s3Client = new AmazonS3Client(txt_Accesskey.Text, txt_Secretkey.Text, bucketRegion);
GetObjectRequest request = new GetObjectRequest();
request.BucketName = bucketName;
request.Key = "Sample.txt";
GetObjectResponse response = s3Client.GetObject(request);
response.WriteResponseStreamToFile(@"C:\Desktop\Sample.txt");
But, I want to download these files as Byte Array. Can anyone please give me a solution for this?
Upvotes: 4
Views: 10725
Reputation: 81493
Just quickly looking at the docs, you maybe able to do this
using (GetObjectResponse response = client.GetObject(request))
bytes = response.ResponseStream.ToArray();
Upvotes: 3