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的冲突