How to override endpoint in AWS-SDK-CPP to connect to minio server at localhost:9000

狂风中的少年 提交于 2019-12-08 04:50:27

问题


I tried something like:

Aws::Client::ClientConfiguration config;
config.endpointOverride = Aws::String("localhost:9000");

It does not work.

It seems that AWS-SDK-CPP by default uses virtual hosting:

https://bucket-name/s3.amazonaws.com

However, to access Minio, we need path style access:

https://localhost:9000/minio/bucket-name

In AWS-SDK-JAVA, there is:

AmazonS3ClientBuilder.withPathStyleAccessEnabled(true)

is there something similar in AWS-SDK-CPP?


回答1:


The switch between path style and virtual hosting is in S3Client constructor:

S3Client(const Aws::Client::ClientConfiguration& clientConfiguration = Aws::Client::ClientConfiguration(), bool signPayloads = false, bool useVirtualAdressing = true);

turn it off, as in:

Aws::Client::ClientConfiguration config;
config.endpointOverride = Aws::String("172.31.30.127:9000");
config.scheme = Aws::Http::Scheme::HTTP;
auto client = Aws::MakeShared<S3Client>("sample_s3_client", config, false, false);


来源:https://stackoverflow.com/questions/47105289/how-to-override-endpoint-in-aws-sdk-cpp-to-connect-to-minio-server-at-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!