如何覆盖 AWS-SDK-CPP 中的端点以连接到位于 localhost:9000 的 minio 服务器

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

我试过类似的方法:

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

没用。

AWS-SDK-CPP 似乎默认使用虚拟主机:

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

但是,要访问 Minio,我们需要路径样式访问:

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

AWS-SDK-JAVA中有:

AmazonS3ClientBuilder.withPathStyleAccessEnabled(true)

AWS-SDK-CPP 中有类似的东西吗?

路径样式和虚拟主机之间的切换在 S3Client 构造函数中:

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

关闭它,如:

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);