0
每當我運行我的程序時,都會收到錯誤「無法連接到端點」。但我知道我可以連接到該存儲桶,因爲我可以使用相同的配置和s3Client成功下載該存儲桶中的文件。它被卡在PutObject()行上。使用C++ SDK將文件上傳到AWS
這是代碼。
const String KEY = "test2.txt";
const String BUCKET = "savefiles2017";
const String fileName = "test2.txt";
Client::ClientConfiguration config;
config.region = Region::US_WEST_2;
config.scheme = Http::Scheme::HTTPS;
S3Client s3Client(Auth::AWSCredentials("XXXXXX", "YYYYYY"), config);
//putting something into s3
PutObjectRequest putObjectRequest;
putObjectRequest.WithBucket(BUCKET).WithKey(KEY);
auto requestStream = MakeShared<FStream>("PutObjectInputStream", fileName.c_str(), ios_base::in);
putObjectRequest.SetBody(requestStream);
auto putObjectOutcome = s3Client.PutObject(putObjectRequest);
if (putObjectOutcome.IsSuccess())
{
cout << "Put object succeeded" << endl;
}
else
{
cout << "Error while putting Object " << putObjectOutcome.GetError().GetExceptionName() <<
" " << putObjectOutcome.GetError().GetMessage() << endl;
}
這些都是包括我使用以及
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
#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/core/utils/memory/stl/AWSStringStream.h>
using namespace Aws;
using namespace Aws::S3;
using namespace Aws::S3::Model;
任何幫助將不勝感激。
的SDK版本有什麼額外的標誌?你能發佈跟蹤日誌嗎? –
我使用NuGet,因此對於AWSSDKCPP-Core,它是版本1.0.128,對於AWSSDKCPP-S3,它是版本1.0.20060301.128。我如何找到跟蹤日誌?我也在Visual Studios上運行。 – karllawson
它也似乎工作,如果我上傳一個空文件。但是,如果我將任何內容放入文件中,它都不會上傳。 – karllawson