Abhishek Pathak
Abhishek Pathak

Reputation: 173

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.

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

Upvotes: 1

Views: 2523

Answers (1)

Norm Johanson
Norm Johanson

Reputation: 3177

I'm guessing this is .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. In your case you would need to call client.PutObjectAsync.

Upvotes: 2

Related Questions