我正在使用相同的代码,但是出现了访问被拒绝的情况。您知道我该如何使用户具有权限通过吗?我正在本地运行。
using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKey, secretKey, RegionEndpoint.SAEast1))
{
var stream = new System.IO.MemoryStream();
var strem = File.OpenRead(_repositorioLocal);
stream.Position = 0;
try
{
PutObjectRequest request = new PutObjectRequest();
request.InputStream = stream;
request.BucketName = bucketName;
//request.Grants = new S3Grant({ us})
request.CannedACL = S3CannedACL.PublicReadWrite;
request.Key = "anexos/" + string.Format("{0}.{1}",idAnexo.ToString(),"pdf");
var response = client.PutObject(request);
if (response.HttpStatusCode == HttpStatusCode.OK)
ret = true;
}
catch(Exception e)
{
stream.Dispose();
}
}