Aws-sdk-cpp: using s3_force_path_style in C++

Created on 26 Jun 2017  Â·  11Comments  Â·  Source: aws/aws-sdk-cpp

Hello,

In the java client http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/Core/Client.html the configuration defines an option s3_force_path in the config options.

What is the method to specify the same option "s3_force_path" using the C++ client.

For example I am using the following code, however I am not able to find as how to give the option s3_force_path

` Aws::Client::ClientConfiguration opts;

        opts.scheme = Aws::Http::Scheme::HTTP;
        opts.region = Aws::String("");

        opts.endpointOverride = Str_endpointOverride;
        opts.verifySSL = verifySSL;
        opts.connectTimeoutMs = 60000;
        opts.requestTimeoutMs = 10000;

        Aws::S3::S3Client s3_client(Aws::Auth::AWSCredentials(access_key_id, secret_access_key),
            opts);`
guidance

Most helpful comment

If it was the same they'd be the same argument. Sign payloads avoids signing the object body during signature calculation (performance improvement) when using tls.

Virtual Addressing = false turns on path style addressing.

Sent from my iPhone

On Jun 26, 2017, at 8:30 PM, gourish2k notifications@github.com wrote:

The constructor is specified as follows

S3Client (const Auth::AWSCredentials &credentials, const Client::ClientConfiguration &clientConfiguration=Client::ClientConfiguration(), bool signPayloads=false, bool useVirtualAdressing=true)

Is the the parameter signPayloads same as s3_force_path in the constructor

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

All 11 comments

It's a constructor argument for the s3 client class.

The constructor is specified as follows

S3Client (const Auth::AWSCredentials &credentials, const Client::ClientConfiguration &clientConfiguration=Client::ClientConfiguration(), bool signPayloads=false, bool useVirtualAdressing=true)

Is the the parameter signPayloads same as s3_force_path in the constructor

If it was the same they'd be the same argument. Sign payloads avoids signing the object body during signature calculation (performance improvement) when using tls.

Virtual Addressing = false turns on path style addressing.

Sent from my iPhone

On Jun 26, 2017, at 8:30 PM, gourish2k notifications@github.com wrote:

The constructor is specified as follows

S3Client (const Auth::AWSCredentials &credentials, const Client::ClientConfiguration &clientConfiguration=Client::ClientConfiguration(), bool signPayloads=false, bool useVirtualAdressing=true)

Is the the parameter signPayloads same as s3_force_path in the constructor

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

The option Virtual Addressing = false is works, thanks for answering the question.

I am having issue with a c++ sample (aws s3 cpp) to upload to minio, I received an error "SDK failed to sign the request".

I have use this constructor like you advised but I still have the issue.

Any idea why I got this error?

#include "pch.h"
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/PutObjectRequest.h>
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include <aws/s3/model/PutObjectRequest.h>
#include <aws/core/auth/AWSCredentialsProvider.h>

int main()
{
    Aws::SDKOptions options;
    Aws::InitAPI(options);
    {
        Aws::Client::ClientConfiguration config;
        config.region = Aws::String("");
        config.verifySSL = false;
        config.connectTimeoutMs = 60000;
        config.requestTimeoutMs = 10000;
        config.endpointOverride = Aws::String("localhost:9000");
        config.scheme = Aws::Http::Scheme::HTTP;
        Aws::S3::S3Client s3_client = Aws::S3::S3Client(Aws::Auth::AWSCredentials("user",
            "user_pswd"), config, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, false);

        Aws::S3::Model::PutObjectRequest request;
        request.SetBucket("toto");
        request.SetKey("totoFile");
        const std::shared_ptr<Aws::IOStream> input_data =
            Aws::MakeShared<Aws::FStream>("SampleAllocationTag",
                "toto.exr",
                std::ios_base::in | std::ios_base::binary);
        request.SetBody(input_data);

        auto outcome = s3_client.PutObject(request);

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

I am also facing same issue here when i am trying multipart upload to minio server. Do we have any alternative for this?

Isn't set useVirtualAddressing worked for you? Or is it a different issue as you just closed?

@singku thank you very much useVirtualAddressing worked. That is the reason i closed that issue. This is different one where verify upload fails for MINIO with error " SDK cannot sign the request"

The original post of this issue was about forcing s3 path style. It's confusing to say you face the same issue but the real issue is about signing when doing multipart upload. They might be related after investigation. But at this step, we don't know. You might want to create a new issue stating clearly with details of what's going wrong with SDK cannot sign the request.

Oh, I see. You just followed the issue of the other guy. But we still want to get more detailed info, as log. Would you please post a new issue for your case? Thanks.

sure will do

Was this page helpful?
0 / 5 - 0 ratings