我可以使用以下代码从Amazon S3存储下载文件
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");
但是,我想将这些文件下载为字节数组。有人可以给我解决方案吗?
答案 0 :(得分:1)
只要快速查看docs,您也许就能做到
using (GetObjectResponse response = client.GetObject(request))
using (var ms = new MemoryStream(response.ResponseStream))
bytes = ms.ToArray();