1
votes

I'm trying to get the an object from S3 using the aws-sdk-cpp, but get "" error. I successfully access the file directly from web browser.

Here my code:

static const char* ALLOCATION_TAG = "App_TransferFiles_TAG";

// Create a client
ClientConfiguration config;
config.scheme = Scheme::HTTP;
config.connectTimeoutMs = 30000;
config.requestTimeoutMs = 30000;

m_s3Client = Aws::MakeShared<S3Client>(ALLOCATION_TAG, config);

TransferClientConfiguration transferConfig;
transferConfig.m_uploadBufferCount = 20;

m_transferClient = Aws::MakeShared<TransferClient>(ALLOCATION_TAG, m_s3Client, transferConfig);

GetObjectRequest getObjectRequest;
getObjectRequest.SetBucket(""MyBucketName");
getObjectRequest.SetKey("My_CONTENT_FILE_KEY");
GetObjectOutcome getObjectOutcome = m_s3Client->GetObject(getObjectRequest);

"m_s3Client->GetObject(getObjectRequest);" return an Error after long waiting!!! Error: "Unable to connect to endpoint"

What I'm missing?

2

2 Answers

2
votes

Region was missing in the ClientConfiguration! All need was to add:

config.region = REGION;
0
votes

I have also encountered this problem. I solved it with:

config.region = Aws::Region::EU_CENTRAL_1; 
config.scheme = Aws::Http::Scheme::HTTPS;
config.connectTimeoutMs = 30000;
config.requestTimeoutMs = 600000;