I am trying to download a file from S3 to a byte array iin .net using c#.
I am following the below method:
var client = new AmazonS3Client(AccessKey, SecretKey, Amazon.RegionEndpoint.EUWEST2);
using (client)
{
MemoryStream ms = new MemoryStream();
GetObjectRequest getObjectRequest = new GetObjectRequest();
getObjectRequest.BucketName = Bucketname;
getObjectRequest.Key = Keyname;
using (var getObjectResponse = client.GetObject(getObjectRequest))
{
getObjectResponse.ResponseStream.CopyTo(ms);
}
}
I referred to a stackoverflow answer and followed the above method.
However I am getting the following error saying;
GetObject is inaccessible due to protection level.
I am just learning S3, I am now confused if this error is because of bucket policy or class scope.