var client = new AmazonS3Client(Amazon.RegionEndpoint.USEast2);
try
{
PutObjectRequest putRequest = new PutObjectRequest
{
BucketName = bucketName,
Key = keyName,
ContentBody = filePath,
ContentType = "text/plain"
};
PutObjectResponse response = client.PutObject(putRequest);
}
我想使用此代码将文件上传到s3存储桶 这是我得到的错误。
Error CS0122 'AmazonS3Client.PutObject(PutObjectRequest)' is inaccessible due to its protection level
答案 0 :(得分:2)
我猜这是.NET Core。在.NET Core中,只有异步版本是公共的,以匹配底层HttpClient在.NET Standard 1.3中支持的内容,这是AWS SDK针对基于.NET Core项目的目标。在您的情况下,您需要致电client.PutObjectAsync
。