有一个简单的客户端代码,它返回错误: 服务器失败,HTTP 状态代码 0
#include <client.h>
#pragma comment(lib, "Ws2_32.lib")
int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::s3::BaseUrl base_url("10.10.100.30:9000");
// Create credential provider.
minio::creds::StaticProvider provider(
"OoV8n5P2XUe5uulSuPZv", "nJh182rvN0cBFFW5ep7ovT0wZ6Yn5BrRXcPbQoum");
// Create S3 client.
minio::s3::Client client(base_url, &provider);
std::string bucket_name = "icons";
minio::s3::ListObjectsArgs args;
args.bucket = bucket_name;
// Optional prefix filter
args.prefix = "icons/";
minio::s3::ListObjectsResult result = client.ListObjects(args);
for (; result; result++) {
minio::s3::Item item = *result;
if (!item) {
//throw std::runtime_error("Error during ListObjects(): " + item.Error().String());
std::cout << item.Error().String() << std::endl;
}
std::cout << item.name << std::endl;
}
return EXIT_SUCCESS;
}
但是服务器可以通过curl访问: 在此输入图片描述
文档只是一堆废话,这就是让它工作所需的一切
int main() {
minio::s3::BaseUrl base_url;
base_url.host = "10.10.100.30";
base_url.port = 9000; //Just specify port
base_url.region = "us-east-1";
base_url.https = false; //And set https false
minio::creds::StaticProvider provider(
"OoV8n5P2XUe5uulSuPZv", "nJh182rvN0cBFFW5ep7ovT0wZ6Yn5BrRXcPbQoum");
minio::s3::Client client(base_url, &provider);
std::string bucket_name = "icons";
minio::s3::UploadObjectArgs args;
args.bucket = bucket_name;
args.object = "Info.svg";
args.filename = "C:\\Users\\zlygm\\Downloads\\Info.svg";
minio::s3::UploadObjectResponse resp = client.UploadObject(args);
if (!resp) {
std::cout << "unable to upload object; " << resp.Error() << std::endl;
return EXIT_FAILURE;
}
std::cout << "'/home/user/Photos/asiaphotos.zip' is successfully uploaded as "
<< "object 'asiaphotos-2015.zip' to bucket 'asiatrip'."
<< std::endl;
return EXIT_SUCCESS;
}