【问题标题】:Using AWS SDK to upload file to S3 in .NET Core使用 AWS SDK 将文件上传到 .NET Core 中的 S3
【发布时间】:2018-04-05 07:47:05
【问题描述】:

我正在尝试使用 this 文档通过 AWS 开发工具包将文件上传到我的 S3 存储桶。不幸的是,似乎没有任何文档给出如何在 .NET Core 中执行此操作的示例,只有如何创建和注入 IAmazonS3 的实例。

这是我所拥有的:

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

当它调用PutObjectAsync() 行时,它会挂起30 秒左右,然后抛出“HTTP 重定向请求失败”异常。

我看到的所有文档都是针对PutObject() 而不是PutObjectAsync()。我的client 实例只公开了异步方法。

【问题讨论】:

    标签: c# amazon-s3 asp.net-core aws-sdk asp.net-core-2.0


    【解决方案1】:

    残酷。我的IAmazonS3 客户指向us-west-1,但它是一个不同的区域(us-west-2)。

    【讨论】:

      猜你喜欢
      • 2014-05-27
      • 2017-01-10
      • 2019-08-19
      • 2019-12-06
      • 1970-01-01
      • 2019-12-16
      • 1970-01-01
      • 1970-01-01
      • 2020-03-17
      相关资源
      最近更新 更多