[英]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. 我正在尝试使用此文档通过AWS开发工具包将文件上传到我的S3存储桶。 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
. 不幸的是,似乎没有任何文档提供有关如何在.NET Core中执行此操作的示例,仅提供了如何创建和注入
IAmazonS3
实例的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. 调用
PutObjectAsync()
行时,它将挂起30秒钟左右,然后引发“ HTTP重定向请求失败”异常。
All the documentation I'm seeing is for PutObject()
not PutObjectAsync()
. 我看到的所有文档都是针对
PutObject()
而不是PutObjectAsync()
。 The client
instance I have only exposes async methods. 我只有
client
实例公开异步方法。
Brutal. 野蛮。 I had my
IAmazonS3
client pointing at us-west-1
, but it was a different region ( us-west-2
). 我的
IAmazonS3
客户端指向us-west-1
,但这是一个不同的区域( us-west-2
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.