微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

AWSSDKCPP S3Client.GetObject

如何解决AWSSDKCPP S3Client.GetObject

Getobject 有问题。 Visual Studio 中的 Intellisense 不断将方法评估为 GetobjectW ...

未解析的外部符号“__declspec(dllimport) public: virtual class Aws::Utils::Outcome __cdecl Aws::S3: :S3Client::GetobjectW(class Aws::S3::Model::GetobjectRequest const &)const " (_imp?GetobjectW@S3Client@S3@Aws@@UEBA?AV?$Outcome@VGetobjectResult @Model@S3@Aws@@V?$AWSError@W4S3Errors@S3@Aws@@@Client@4@@Utils@3@AEBVGetobjectRequest@Model@23@@Z)

这是我的包含

#include <aws/core/Aws.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/PutObjectRequest.h>
#include <aws/s3/model/GetobjectRequest.h>
#include <aws/s3/model/DeleteObjectRequest.h>
#include <aws/s3/model/GetBucketLocationRequest.h>
#include <aws/s3/model/ListObjectsRequest.h>

所有其他方法都有效。放置作品、删除作品、列出作品。一切正常。项目设置为 VS 2017。我只遇到 Getobject 的问题,正如我所说,intellisense 看到除 Getobject 之外的所有其他方法,它评估为 GetobjectW

Client::ClientConfiguration config;

config.region = Region::US_EAST_2;
config.scheme = Http::Scheme::HTTPS;
config.connectTimeoutMs = 30000;
config.requestTimeoutMs = 30000;

S3Client s3Client(Auth::AWSCredentials(ACCESS_KEY,SECRET_KEY),config);

GetobjectRequest getobjectRequest;
getobjectRequest.WithBucket(bucket)
  .WithKey(fileKey);

// //Getobject is Having issues here where it is not being found in referenced assembly it keeps being called GetobjectW... 
// //It is perhaps the case there is a missing required reference for the method?
GetobjectOutcome getobjectOutcome = s3Client.Getobject(getobjectRequest);

解决方法

解决于 https://github.com/aws/aws-sdk-cpp/issues/625

答案是:

必须在 aws 包括以下内容之前 #undef GetObject:

#undef GetObject
#include <aws/core/Aws.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/GetObjectRequest.h>

这是与Windows.h的冲突

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。