简体   繁体   English

如何使用AWS .NET C#SDK将文件上传到AWS S3存储桶

[英]how to upload a file to aws s3 bucket using aws .net c# sdk

 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);
        }

I want to upload a file to s3 bucket using this code this is the error i am getting. 我想使用此代码将文件上传到s3存储桶,这是我收到的错误。

Error   CS0122  'AmazonS3Client.PutObject(PutObjectRequest)' is inaccessible due to its protection level    

I'm guessing this is .NET Core. 我猜这是.NET Core。 In .NET Core only the async versions are public to match what the underlying HttpClient supports in .NET Standard 1.3 which is what the AWS SDK targets for .NET Core based projects. 在.NET Core中,只有异步版本才公开,以匹配.NET Standard 1.3中底层HttpClient支持的功能,这是AWS SDK针对基于.NET Core的项目的目标。 In your case you would need to call client.PutObjectAsync . 在您的情况下,您需要调用client.PutObjectAsync

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM