2016-09-02 26 views
1

私はAWS S3ストレージにaviファイルをアップロードするためのファイルをC++に持っています。 プログラムは以下の通りです。PutObjectエラー:aws-cpp-sdkを使用してAWS S3にファイルをアップロードするとき

#include <aws/core/Aws.h> 
#include <aws/s3/S3Client.h> 
#include <aws/core/utils/HashingUtils.h> 
#include <aws/s3/model/PutObjectRequest.h> 
#include <iostream> 
#include <fstream> 

using namespace Aws::S3::Model; 
using namespace std; 
using namespace Aws::Utils; 

static const char* KEY = "test.avi"; 
static const char* BUCKET = "testnmn"; 

int main() 
{ 
    Aws::SDKOptions options; 
    Aws::InitAPI(options); 

    const Aws::String bucket_name = BUCKET; 
    const Aws::String key_name = KEY; 
    const Aws::String dir_name = "/home/Softwares/Projects/S3upload/build"; 

    std::cout << "Uploading " << key_name << " to S3 bucket: " << 
     bucket_name << std::endl; 

    Aws::S3::S3Client s3_client; 

    Aws::S3::Model::PutObjectRequest object_request; 
    object_request.WithBucket(bucket_name).WithKey(key_name); 

    auto input_data = Aws::MakeShared<Aws::FStream>(key_name.c_str(), dir_name.c_str(), std::ios_base::in); 

    object_request.SetBody(input_data); 

    auto put_object_outcome = s3_client.PutObject(object_request); 

    if(put_object_outcome.IsSuccess()) { 
     std::cout << "Done!" << std::endl; 
    } 
    else { 
     std::cout << "PutObject error: " << 
      put_object_outcome.GetError().GetExceptionName() << " " << 
      put_object_outcome.GetError().GetMessage() << std::endl; 
    } 

    Aws::ShutdownAPI(options); 

    return 0; 
} 

私はexeファイルを実行すると、私はそのエラーと間違っている可能性が何

Uploading test.avi to S3 bucket: testnmn 
PutObject error: PermanentRedirect Unable to parse ExceptionName: PermanentRedirect Message: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. 

としてエラーがありますか?あなたがアクセスしようとしているバケットは(私は私たち-東-1であると信じてデフォルトよりも、)別の領域に作成されているように見えます

おかげ

+0

あなたがこの問題を解決しましたか?もしあなたがしていれば、それを解決する方法を分かち合うことができますか? – gkhanacer

答えて

1

&は、したがってエンドポイントが一致していません。

あなたはClientConfigurationを使用して地域を設定することができます。

Aws::Client::ClientConfiguration myConf; 
myConf.region = Aws::Region::US_WEST_2; 
Aws::S3::S3Client s3_client(myConf); 
関連する問題