2016-04-03 143 views
0

我想從S3使用aws-sdk-cpp獲得一個對象,但得到「」錯誤。 我直接從網絡瀏覽器成功訪問文件。AWS S3 aws-sdk-cpp GetObject「無法連接到端點」

這裏我的代碼:

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);」長時間等待後返回一個錯誤! 錯誤:「無法連接到端點」

我失蹤了什麼?

回答

2

ClientConfiguration中的區域丟失了! 都需要是增加:

config.region = REGION; 
0

我也遇到了這個問題。我解決了它:

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