c++amazon-web-servicesamazon-s3aws-sdk-cpp

no matching function for call to ‘Aws::S3::S3Client::S3Client(Aws::Auth::AWSCredentials, Aws::Client::ClientConfiguration&)’


main.cpp: In function ‘void downloadFile(const string&, const string&, std::ostream&)’:

main.cpp:23:95: error: no matching function for call to ‘Aws::S3::S3Client::S3Client(Aws::Auth::AWSCredentials, Aws::Client::ClientConfiguration&)’ Aws::S3::S3Client s3Client(Aws::Auth::AWSCredentials(ACCESS_KEY, SECRET_KEY), clientConfig);

In file included from main.cpp:3:

install/include/aws/s3/S3Client.h:100:9: note: candidate: ‘Aws::S3::S3Client::S3Client(const std::shared_ptrAws::Auth::AWSCredentialsProvider&, const Aws::Client::ClientConfiguration&, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy, bool, Aws::S3::US_EAST_1_REGIONAL_ENDPOINT_OPTION)’

S3Client(const std::shared_ptrAws::Auth::AWSCredentialsProvider& credentialsProvider, install/include/aws/s3/S3Client.h:100:9: note: candidate expects 5 arguments, 2 provided

#include <aws/lambda-runtime/runtime.h>
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/GetObjectRequest.h>
#include <aws/core/auth/AWSCredentials.h>
#include <aws/core/client/ClientConfiguration.h>
//#include <aws/core/auth/AWSCredentialsProvider.h>

using namespace aws::lambda_runtime;

Aws::SDKOptions options;

static const char* ENDPOINT_URL = "endpoint";
static const char* ACCESS_KEY = "accesskey";
static const char* SECRET_KEY = "secretkey";

void downloadFile(const std::string& bucketName, const std::string& objectKey, std::ostream& outputStream) {
    Aws::Client::ClientConfiguration clientConfig;
    clientConfig.endpointOverride = ENDPOINT_URL;
    clientConfig.scheme = Aws::Http::Scheme::HTTP;
    clientConfig.connectTimeoutMs = 30000;
    clientConfig.requestTimeoutMs = 30000;
    clientConfig.region = "us-west-2";

    Aws::S3::S3Client s3Client(Aws::Auth::AWSCredentials(ACCESS_KEY, SECRET_KEY), clientConfig);

}

Solution

  • I had the same issue as you did. It appears that a constructor that used to exist previously has been modified in the latest SDK and default values have been removed. Among the new ones, this is the one that closely matches. So you can either modify the constructor, or I would suggest you pass the values that it now requires.

    S3Client(const Aws::Auth::AWSCredentials& credentials,
         const Aws::Client::ClientConfiguration& clientConfiguration,
         Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy signPayloads,
         bool useVirtualAddressing,
         Aws::S3::US_EAST_1_REGIONAL_ENDPOINT_OPTION USEast1RegionalEndPointOption = Aws::S3::US_EAST_1_REGIONAL_ENDPOINT_OPTION::NOT_SET);
    

    Use this to create the object instead.

    Aws::S3::S3Client S3_Client = Aws::S3::S3Client(Aws::Auth::AWSCredentials(ACCESS_KEY, SECRET_KEY), clientConfig, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, true);