适用于 .NET 的 AWS 开发工具包 - IAmazonS3 不包含 'PutObject' 的定义

AWS SDK for .NET - IAmazonS3 does not contain definition for 'PutObject'

我正在尝试创建一个允许用户将文档上传到 S3 的 Lambda 函数。为此,我遵循了 SDK 的文档,其中指出有一种方法 "PutObject" 允许我将对象放入存储桶中。当我编写代码时,出现以下编译错误:

IAmazonS3 does not contain definition for 'PutObject' and no extension method 'PutObject' accepting first argument of type 'IAmazonS3' could be found.

这是我目前正在使用的代码:

S3Client = new AmazonS3Client("*********", "**********************", Amazon.RegionEndpoint.USEast1);
PutObjectRequest putRequest = new PutObjectRequest();
putRequest.BucketName = _bucket;
putRequest.ContentType = ContentType;
putRequest.ContentBody = Bytes;
var s3Response = S3Client.PutObject(putRequest);
return s3Response.HttpStatusCode.ToString();

我已经更新了所有 NuGet 包并安装了 AWSSDK.S3 v3.3.5.3 包。当我查看对象浏览器时,我只看到异步方法。文档中没有提到 PutObject 方法的列表。谁能指出我为什么这不起作用的正确方向?

如果您只看到 Async 操作,您的项目可以是便携式 Class 库或 Unity 项目,因为 NuGet 包管理器将安装正确的程序集取决于您的项目类型。

For PCL and Unity this operation is only available in asynchronous form.

参见 AmazonS3Client.PutObject

更新

如果您使用 .NET Core:

,同样适用

The AWS SDK for .NET supports applications written for .NET Core. AWS service clients only support asynchronous calling patterns in .NET core. This also affects many of the high level abstractions built on top of service clients like Amazon S3's TransferUtility which will only support asynchronous calls in the .NET Core environment. For details, see Configuring the AWS SDK for .NET with .NET Core.

参见 Platforms Supported by the AWS SDK for .NET