我正在尝试使用aws-sdk-cpp从S3获取对象,但出现“”错误。
我直接从Web浏览器成功访问了文件。

这是我的代码:

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);”长时间等待后返回错误!!!
错误:“无法连接到端点”

我缺少什么?

最佳答案

ClientConfiguration中缺少区域!
所有需要添加的是:

config.region = REGION;

08-19 08:09