每当我运行程序时,都会出现“无法连接到终端点”的错误。但我知道我可以连接到那个桶,因为我可以使用相同的配置和s3Client成功下载该桶中的文件。它卡在PutObject()行。
以下是代码。
以下是代码。
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;
非常感谢您的帮助。