mellis481
mellis481

Reputation: 4148

Using AWS SDK to upload file to S3 in .NET Core

I'm attempting to use this documentation to upload a file to my S3 bucket using the AWS SDK. Unfortunately, there does not seem to be any documentation giving an example of how to do this in .NET Core, only how to create and inject an instance of IAmazonS3.

Here is what I have:

private IAmazonS3 client; //Being injected
private string bucketName;

using (client)
{
    var request = new PutObjectRequest
    {
        BucketName = bucketName,
        Key = "keyTest",
        ContentBody = "sample text"
    };
    var response = await client.PutObjectAsync(request);
}

When it calls the PutObjectAsync() line, it hangs for 30 seconds or so and then throws a "The HTTP redirect request failed" exception.

All the documentation I'm seeing is for PutObject() not PutObjectAsync(). The client instance I have only exposes async methods.

Upvotes: 3

Views: 3281

Answers (1)

mellis481
mellis481

Reputation: 4148

Brutal. I had my IAmazonS3 client pointing at us-west-1, but it was a different region (us-west-2).

Upvotes: 6

Related Questions