本文介绍了如何覆盖AWS-SDK-CPP中的终端节点以连接到localhost:9000上的minio服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试过类似的事情:
Aws::Client::ClientConfiguration config;
config.endpointOverride = Aws::String("localhost:9000");
它不起作用.
默认情况下,似乎AWS-SDK-CPP使用虚拟主机:
It seems that AWS-SDK-CPP by default uses virtual hosting:
https://bucket-name/s3.amazonaws.com
但是,要访问Minio,我们需要访问路径样式:
However, to access Minio, we need path style access:
https://localhost:9000/minio/bucket-name
在AWS-SDK-JAVA中,有:
In AWS-SDK-JAVA, there is:
AmazonS3ClientBuilder.withPathStyleAccessEnabled(true)
AWS-SDK-CPP中是否有类似的东西?
is there something similar in AWS-SDK-CPP?
推荐答案
路径样式和虚拟主机之间的切换在S3Client构造函数中:
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);
将其关闭,例如:
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);
这篇关于如何覆盖AWS-SDK-CPP中的终端节点以连接到localhost:9000上的minio服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!