2017-06-22 60 views
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; 

使用しています任意の助けをいただければ幸いことを含んでいます。

+0

SDKのバージョンは何ios_base::binaryの余分なフラグを追加する必要がありました

auto requestStream = MakeShared<FStream>("PutObjectInputStream", fileName.c_str(), ios_base::in | ios_base::binary); 

にライン

auto requestStream = MakeShared<FStream>("PutObjectInputStream", fileName.c_str(), ios_base::in); 

を変更しなければなりませんでしたか?トレースログを投稿できますか? –

+0

私はNuGetを使用していますので、AWSSDKCPP-Coreではバージョン1.0.128、AWS​​SDKCPP-S3ではバージョン1.0.20060301.128です。トレースログはどのようにして見つけられますか?また、私はVisual Studiosで走っています。 – karllawson

+0

空のファイルをアップロードするとうまくいくようです。しかし、ファイルに内容を書き込むとアップロードされません。 – karllawson

答えて

0

私はそれを修正する方法を考え出しました。私は、だから私はちょうど

関連する問題