简体   繁体   English

使用AWS开发工具包将文件上传到.NET Core中的S3

[英]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.

相关问题 AWS S3 文件上传 .NET SDK (.NET Core) 无法将数据写入传输连接 - AWS S3 File Upload .NET SDK (.NET Core) Unable to write data to the transport connection 使用 C# 将文件上传到 AWS S3,而不使用 AWS SDK - Upload a file to AWS S3 using C# without using AWS SDK 将大文件上传到.Net中的aws S3服务器(asp.net核心) - Upload large file to aws S3 server in .Net (asp.net core) 使用AWS S3 SDK for .NET从Amazon S3下载并行批处理文件 - Parallel batch file download from Amazon S3 using AWS S3 SDK for .NET AWS .NET SDK直接上传到S3-预签名URL - AWS .NET SDK Direct Upload to S3 - Pre Signed URL -AWS C#.Net Core-如何将.jpg图像上传到S3存储桶而不将其另存为文件 - -AWS C# .Net Core- How to upload a .jpg image to S3 bucket without saving it as a file 使用AWS SDK进行S3上载的带宽限制 - Bandwidth throttling for S3 upload using AWS SDK 使用AWS .NET SDK将文件上载到S3存储桶时,任务被取消了异常? - Task was cancelled exception when uploading file to S3 bucket using AWS .NET SDK? 有没有办法使用适用于 .NET 的 AWS SDK 将对象从 S3 存储桶下载到文件目标? - Is there a way to download an object from S3 bucket to a file destination using AWS SDK for .NET? 在.net上将AWS开发工具包与localstack一起使用(TransferUtility / S3-设置终端节点) - Using AWS SDK on .net with localstack (TransferUtility/S3 - setting endpoint)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM