Giter Club home page Giter Club logo

minio-cpp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

minio-cpp's Issues

Compilation Error: ld Returns 1, Undefined Reference to dlopen and Other Functions

root@lbh-virtual-machine:/home/lbh/minio-cpp# cmake --build ./build --config Release
[ 10%] Built target miniocpp
[ 11%] Linking CXX executable GetObjectProgress
../vcpkg_installed/x64-linux/debug/lib/libcrypto.a(libcrypto-lib-dso_dlfcn.o):在函数‘dlfcn_load’中:
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:116:对‘dlopen’未定义的引用
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:118:对‘dlerror’未定义的引用
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:138:对‘dlclose’未定义的引用
../vcpkg_installed/x64-linux/debug/lib/libcrypto.a(libcrypto-lib-dso_dlfcn.o):在函数‘dlfcn_unload’中:
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:161:对‘dlclose’未定义的引用
../vcpkg_installed/x64-linux/debug/lib/libcrypto.a(libcrypto-lib-dso_dlfcn.o):在函数‘dlfcn_bind_func’中:
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:186:对‘dlsym’未定义的引用
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:188:对‘dlerror’未定义的引用
../vcpkg_installed/x64-linux/debug/lib/libcrypto.a(libcrypto-lib-dso_dlfcn.o):在函数‘dlfcn_pathbyaddr’中:
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:422:对‘dladdr’未定义的引用
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:440:对‘dlerror’未定义的引用
../vcpkg_installed/x64-linux/debug/lib/libcrypto.a(libcrypto-lib-dso_dlfcn.o):在函数‘dlfcn_globallookup’中:
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:447:对‘dlopen’未定义的引用
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:450:对‘dlsym’未定义的引用
/home/lbh/minio-cpp/vcpkg-master/buildtrees/openssl/x64-linux-dbg/../src/nssl-3.1.3-22892fd447.clean/crypto/dso/dso_dlfcn.c:451:对‘dlclose’未定义的引用
collect2: error: ld returned 1 exit status
examples/CMakeFiles/GetObjectProgress.dir/build.make:105: recipe for target 'examples/GetObjectProgress' failed
make[2]: *** [examples/GetObjectProgress] Error 1
CMakeFiles/Makefile2:258: recipe for target 'examples/CMakeFiles/GetObjectProgress.dir/all' failed
make[1]: *** [examples/CMakeFiles/GetObjectProgress.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

How to resolve this issue, please help me

undefined reference to minio::utils::startsWith

Hi,

i installed minio-cpp using vcpkg
but during cmake build i get the following error
in function minio::creds::checkLoopbackHost(std::__cxx11::basic_string<char, std::char_traits, std::allocator >)':
main.cpp:(.text+0x2a6): undefined reference to minio::utils::StartsWith(std::basic_string_view<char, std::char_traits<char> >, std::basic_string_view<char, std::char_traits<char> >)'

all i am doing in my main.cpp is #include <miniocpp/client.h>

my cmake file looks like this

cmake_minimum_required(VERSION 3.0)

project(MY_PROJECT)

set(SOURCES
    src/main.cpp
    src/web-server/server.cpp
    # Add more source files as needed
)

include_directories(include)

# Find packages
find_package(OpenSSL REQUIRED)
find_package(httplib REQUIRED)

# Add executable target
add_executable(${PROJECT_NAME} ${SOURCES})

# Link the executable with cpp-httplib and OpenSSL
target_link_libraries(MY_PROJECT PRIVATE OpenSSL::SSL OpenSSL::Crypto httplib::httplib)

# Set C++ standard (e.g., C++11, C++14, C++17, etc.)
set(CMAKE_CXX_STANDARD 11)

# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

i am working with ubuntu 22

Build on ubuntu18.04

Unable to build due to:
CMake Error at CMakeLists.txt:57 (find_package): Could not find a package configuration file provided by "unofficial-curlpp"
Cannot find package on linux

Signature Mismatch Issue with GetPresignedObjectUrl() in MinIO C++ SDK

I encountered an issue when generating a presigned URL using the GetPresignedObjectUrl() method from the MinIO C++ SDK. Upon attempting to access this URL, I received an error indicating that "The request signature we calculated does not match the signature you provided. Check your key and signing method (SignatureDoesNotMatch)." I have verified that both my accesskey and secretkey are correct.

My MinIO server is deployed using Docker. The SDK version was the latest, compiled from the official GitHub repository. Notably, when I obtain a presigned URL using the mc client, the generated URL works fine. Moreover, if I use the same SDK to access the official MinIO demo server at play.min.io, the URL returned by the same code also works properly. I have also checked the system time synchronization to ensure that the time on my client and server is in sync.

Could you please help me identify the possible cause of this issue?

code:
#include "client.h"

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::s3::BaseUrl base_url("192.168.15.17:9000",false);

// Create credential provider.
minio::creds::StaticProvider provider(
"Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");

// Create S3 client."youraccesskey", "yoursecretkey"
minio::s3::Client client(base_url, &provider);
// Create bucket exists arguments.
minio::s3::BucketExistsArgs args;
args.bucket = "whotest";

// Call bucket exists.
minio::s3::BucketExistsResponse resp = client.BucketExists(args);

// Handle response.
if (resp) {
if (resp.exist) {
std::cout << "my-bucket exists" << std::endl;
} else {
std::cout << "my-bucket does not exist" << std::endl;
}
} else {
std::cout << "unable to do bucket existence check; "
<< resp.Error().String() << std::endl;
}

// Create get presigned object url arguments.
minio::s3::GetPresignedObjectUrlArgs args1;

args1.bucket = "whotest";
args1.object = "photo.png";
args1.method = minio::http::Method::kGet;
args1.expiry_seconds = 60 * 60 * 24 * 7; // 7 day.

// Call get presigned object url.
minio::s3::GetPresignedObjectUrlResponse resp1 =
client.GetPresignedObjectUrl(args1);

// Handle response.
if (resp1) {
std::cout << "presigned URL to get object: " << resp1.url << std::endl;
} else {
std::cout << "unable to get presigned object url; " << resp1.Error().String()
<< std::endl;
}

return 0;
}

I have an SDK request problem

Hi,I have an SDK request problem,I use the following code, return “MakeBucket(): invalid response received; status code: 400; content-type: text/xml; charset=utf-8”,You know why?

code:
minio::s3::MakeBucketArgs args1;
args1.bucket = "test";
minio::s3::MakeBucketResponse resp1 = client.MakeBucket(args1);
if (!resp1)
{
throw std::runtime_error("MakeBucket(): " + resp1.Error().String());
}

GetObjectResponse doesn't keep data (resp.data)

Hi,
I'm new to both MINIO and minio-cpp.

From GetObject.cc example,
I printed the data of GetObjectResponse as below, but it printed nothing.

minio::s3::GetObjectResponse resp = client.GetObject(args);
if (resp) {
std::cout << resp.data ;
}

Within datafunc, args.datachunk is available.
However, I'd like to compute the data using GPU(i.e., CUDA), so computing within datafunc can't be an option for me.

To fix this issue, I added
body += std::string(buffer ,length); to http.cc at line 160

Which way is a proper scheme of MINIO?

  1. Response keeps data when GetObject() is invoked w\ datafunc (my method)
  2. Allowing GetObject() can be invoked w\o datafunc (currently this case is not allowed by here)
  3. Response keeps data when both GetObject() is invoked w/ and w\o datafunc

thank you.

FYI, my environment as below:
OS: Ubuntu 18.04
g++: v8.4.0
nvcc: V11.8.89 (CUDA 11.8)

Clang-format-18 formats the source code differently

My clang-format gives clang-format version 18.0.0git (https://github.com/llvm/llvm-project.git 02e02b9a8f0e22ffc0d6c070b132a88e94f02861) and it give different formatted source code.

Q1: can we log/print the used clang version just for reproducibility. Ubuntu clang-format version 14.0.0-1ubuntu1.1 works.
Q2: can we check-in the used style-sheet such that we are less dependent on the LLVM version that people happen to have installed.

ListenBucketNotification endless loop

In baseclient.cc in function ListenBucketNotification, the data from the notification gets added in every iteration in the while(true) loop, resulting in a endless loop. You get the same notification over and over again. Moving "data += args.datachunk;" outside of the whileloop fixed the problem for me. But im not sure if thats the intended way.

Old
req.datafunc = [&func = func, &data = data](http::DataFunctionArgs args) -> bool { while (true) { data += args.datachunk; size_t pos = data.find('\n'); if (pos == std::string::npos) return true; std::string line = data.substr(0, pos);

New
req.datafunc = [&func = func, &data = data](http::DataFunctionArgs args) -> bool { data += args.datachunk; while (true) { size_t pos = data.find('\n'); if (pos == std::string::npos) return true; std::string line = data.substr(0, pos);

Linking problems on Ubuntu 20.04

Hi, I cloned the Git repo and I either installed with vcpkg/build from source, but I have linking problems with an external library "curlpp". Is there any problem with the library now or do I need to install somewhere other dependencies manually?

To reproduce this error, I just had to import <miniocpp/client.h> in my project.

Attached log of the linking error:

/usr/bin/ld: /usr/local/lib/libminiocpp.a(utils.cc.o): in function `minio::utils::CRC32(std::basic_string_view<char, std::char_traits<char> >)':
/home/bulbo/Downloads/minio-cpp/src/utils.cc:55: undefined reference to `crc32'
/usr/bin/ld: /usr/local/lib/libminiocpp.a(utils.cc.o): in function `minio::utils::EncodePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
/home/bulbo/Downloads/minio-cpp/src/utils.cc:139: undefined reference to `curlpp::escape(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /usr/local/lib/libminiocpp.a(utils.cc.o): in function `minio::utils::Sha256Hash[abi:cxx11](std::basic_string_view<char, std::char_traits<char> >)':
/home/bulbo/Downloads/minio-cpp/src/utils.cc:150: undefined reference to `EVP_MD_CTX_new'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:156: undefined reference to `EVP_sha256'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:156: undefined reference to `EVP_DigestInit_ex'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:161: undefined reference to `EVP_DigestUpdate'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:166: undefined reference to `EVP_sha256'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:166: undefined reference to `EVP_MD_get_size'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:167: undefined reference to `CRYPTO_malloc'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:173: undefined reference to `EVP_DigestFinal_ex'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:174: undefined reference to `CRYPTO_free'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:179: undefined reference to `EVP_MD_CTX_free'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:188: undefined reference to `CRYPTO_free'
/usr/bin/ld: /usr/local/lib/libminiocpp.a(utils.cc.o): in function `minio::utils::Base64Encode[abi:cxx11](std::basic_string_view<char, std::char_traits<char> >)':
/home/bulbo/Downloads/minio-cpp/src/utils.cc:194: undefined reference to `BIO_s_mem'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:194: undefined reference to `BIO_new'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:195: undefined reference to `BIO_f_base64'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:195: undefined reference to `BIO_new'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:196: undefined reference to `BIO_push'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:198: undefined reference to `BIO_write'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:199: undefined reference to `BIO_ctrl'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:202: undefined reference to `BIO_ctrl'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:205: undefined reference to `BIO_free_all'
/usr/bin/ld: /usr/local/lib/libminiocpp.a(utils.cc.o): in function `minio::utils::Md5sumHash[abi:cxx11](std::basic_string_view<char, std::char_traits<char> >)':
/home/bulbo/Downloads/minio-cpp/src/utils.cc:211: undefined reference to `EVP_MD_CTX_new'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:217: undefined reference to `EVP_md5'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:217: undefined reference to `EVP_DigestInit_ex'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:222: undefined reference to `EVP_DigestUpdate'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:227: undefined reference to `EVP_md5'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:227: undefined reference to `EVP_MD_get_size'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:228: undefined reference to `CRYPTO_malloc'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:234: undefined reference to `EVP_DigestFinal_ex'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:235: undefined reference to `CRYPTO_free'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:240: undefined reference to `EVP_MD_CTX_free'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:243: undefined reference to `CRYPTO_free'
/usr/bin/ld: /usr/local/lib/libminiocpp.a(utils.cc.o): in function `minio::utils::Multimap::ToQueryString[abi:cxx11]()':
/home/bulbo/Downloads/minio-cpp/src/utils.cc:339: undefined reference to `curlpp::escape(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:339: undefined reference to `curlpp::escape(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /usr/local/lib/libminiocpp.a(utils.cc.o): in function `minio::utils::Multimap::GetCanonicalQueryString[abi:cxx11]()':
/home/bulbo/Downloads/minio-cpp/src/utils.cc:415: undefined reference to `curlpp::escape(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: /home/bulbo/Downloads/minio-cpp/src/utils.cc:415: undefined reference to `curlpp::escape(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status

is vcpkg arm64-osx version outdated?

I tried to install miniocpp with vcpkg on my mac M1 and when I look at the include folder in miniocpp (~/vcpkg/installed/arm64-osx/include/miniocpp) I can only see the following:

├── s3.h
├── s3_headers.h
├── s3_http.h
├── s3_io.h
├── s3_signature_v2.h
└── s3_types.h

This doesn't match with what's on the repository. Is it because the version is outdated?

Issue with using libminiocpp.a

I encountered an issue when building my program using libminiocpp.a. My compilation LDFLAGS are: -L/usr/local/lib -lminiocpp -L/home/xxx/minio-cpp/build/vcpkg_installed/x64-linux/lib -lcurlpp -lcurl -lssl -lcrypto -linih -lINIReader -lpugixml -lz. The compilation is successful, but when I try to use it, I encounter the following error: undefined symbol: _ZN5minio2s37BaseUrlC1ESsbSs

should reuse the http connetion in multi operation?

Dear,
I see that minio::s3::Client create new http connections for each operation. That will consume much ports in high concurrency scenario.

So, I want to reuse the http connection to avoid that problem. How can I do?

many thanks.

Conan package.

Hi guys ! Would it be possible to distribute the package via Conan also ?

fix some warnings during compile

[ 25%] Building CXX object src/CMakeFiles/miniocpp.dir/utils.cc.o
/home/harsha/go/src/github.com/minio/minio-cpp/src/utils.cc: In member function ‘std::string minio::utils::Time::ToISO8601UTC()’:
/home/harsha/go/src/github.com/minio/minio-cpp/src/utils.cc:270:25: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘__suseconds_t’ {aka ‘long int’} [-Wformat=]
  270 |   snprintf(buf, 64, "%03d", tv_.tv_usec);
      |                      ~~~^   ~~~~~~~~~~~
      |                         |       |
      |                         int     __suseconds_t {aka long int}
      |                      %03ld
/home/harsha/go/src/github.com/minio/minio-cpp/src/utils.cc: In static member function ‘static minio::utils::Time minio::utils::Time::FromISO8601UTC(const char*)’:
/home/harsha/go/src/github.com/minio/minio-cpp/src/utils.cc:283:17: warning: format ‘%u’ expects argument of type ‘unsigned int*’, but argument 3 has type ‘suseconds_t*’ {aka ‘long int*’} [-Wformat=]
  283 |   sscanf(rv, ".%u", &tv_usec);
      |                ~^   ~~~~~~~~
      |                 |   |
      |                 |   suseconds_t* {aka long int*}
      |                 unsigned int*
      |                %lu
[ 27%] Building CXX object src/CMakeFiles/min

memory leak

when use minio-cpp project I found in function "minio::s3::Client::PutObject(PutObjectArgs args)" has dismatch new/free[line 688-695].

[help wanted]add a function to get upload progress but test failed

the line with comment "// xyq " is my code
at http.h
struct Request { Method method; http::Url url; utils::Multimap headers; std::string_view body = ""; DataFunction datafunc = NULL; void* userdata = NULL; bool debug = false; bool ignore_cert_check = false; std::string ssl_cert_file; std::string key_file; std::string cert_file;`

Request(Method method, Url url);
Response Execute();
operator bool() const {
if (method < Method::kGet || method > Method::kDelete) return false;
return url;
}

int GetUploadProgress() { return upload_progress; } // xyq

int ProgressCallback(double dltotal, double dlnow, const double ultotal, const double ulnow); // xyq

private:
static int upload_progress; // xyq
Response execute();
}; // struct Request

at http.cc
#include "http.h"

int minio::http::Request::upload_progress = 0;

Response response;
response.datafunc = datafunc;
response.userdata = userdata;

using namespace std::placeholders;
request.setOpt(new curlpp::options::NoProgress(false)); // xyq
request.setOpt(new curlpp::options::ProgressFunction(
std::bind(&http::Request::ProgressCallback, this, _1, _2, _3, _4))); // xyq
request.setOpt(new curlpp::options::WriteFunction(
std::bind(&Response::ResponseCallback, &response, &requests, &request, _1,
_2, _3)));

int left = 0;
requests.add(&request);

int minio::http::Request::ProgressCallback(double dltotal, double dlnow, const double ultotal, const double ulnow) { //xyq
if (ultotal > -0.1 && ultotal < 0.1) { // xyq
return -1; //xyq
} // xyq
int ulPos = (int) ((ulnow/ultotal)*100); // xyq
this->upload_progress = ulPos; // xyq
return 0; // xyq
} // xyq

at baseclient.h
class BaseClient {
protected:
BaseUrl& base_url_;
creds::Provider* provider_ = NULL;
std::map<std::string, std::string> region_map_;
bool debug_ = false;
bool ignore_cert_check_ = false;
std::string ssl_cert_file_;
std::string user_agent_ = DEFAULT_USER_AGENT;
minio::http::Request *req; // xyq
at client.hpublic: Client(BaseUrl& base_url, creds::Provider* provider = NULL); ComposeObjectResponse ComposeObject(ComposeObjectArgs args); CopyObjectResponse CopyObject(CopyObjectArgs args); DownloadObjectResponse DownloadObject(DownloadObjectArgs args); ListObjectsResult ListObjects(ListObjectsArgs args); PutObjectResponse PutObject(PutObjectArgs args); UploadObjectResponse UploadObject(UploadObjectArgs args); RemoveObjectsResult RemoveObjects(RemoveObjectsArgs args); int GetUploadProgress() { return req->GetUploadProgress(); } // xyq`

How to set client with secure=false

I have minio server by python

`
from minio import Minio

client = Minio("my-endpoint", "access_key", "secret_key")
`

run this code with SSLError, but add secure= False that run well, like bottom

`
from minio import Minio

client = Minio("my-endpoint", "access_key", "secret_key", secure=False)
`

my minio-cpp client also with the error, but i don't how to add the "secure" with minio-cpp.

Vcpkg installation problem

I did vcpkg install minio-cpp and Qt Creator could not find package configuration file.
"error: Could not find a package configuration file provided by "miniocpp" with any of the following names: miniocppConfig.cmake miniocpp-config.cmake Add the installation prefix of "miniocpp" to CMAKE_PREFIX_PATH or set "miniocpp_DIR" to a directory containing one of the above files. If "miniocpp" provides a separate development package or SDK, be sure it has been installed."
Vcpkg can install another libraries ant they work in Qt Creator.
My OS is Ubuntu 23.10
What can corrupt installation?

'std::out_of_range' error for size

I encountered the following error when trying to list all the objects in a bucket recursively:

terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi

It turns out the object size is being converted from a string to a int
It crashed when the file I was listing was out of range for stoi ("10814770399" bytes in my case)

I changed stoi() to stol() on line 231 here (https://github.com/minio/minio-cpp/blob/main/src/response.cc#L231) on my local copy of the library and rebuilt it.
and after that I was able to list all the objects without error.

Is this something that can be addressed/fixed? It worked for me, but I am unsure if this is a proper solution.
If it is, I am willing to create a PR for it.

SDK problems.

Installed latest sdk on updated Ubuntu 18.04.6 LTS, 5.4.0-52-generic via vcpkg install minio-cpp.
Compiling the example OK, but running it results in nothing and no error no matter what credentials, however - wrong url results in error.
Populated storage according to https://github.com/minio/mc/releases without any issues.
Any ideas?

[fatal bug] std::localtime and std::gmtime not thread safe

In my process, there are multi threads that use the client . I found that some request Incidentally receive a 403 response. Incidentally ! It's very Confusing. The 403 response has 3 different error message : [AccessDenied, SignatureDoesNotMatch, RequestTimeTooSkewed].
The Reason is : [std::localtime and std::gmtime] in minio::utils::Time::ToUTC() not thread safe . the method return a static struct.

std::tm* minio::utils::Time::ToUTC() {
  std::tm* t = new std::tm;
  *t = utc_ ? *std::localtime(&tv_.tv_sec) : *std::gmtime(&tv_.tv_sec);
  return t;
}

In my test project: https://github.com/hanmenghao1995/minio-issue-test

void fun(int threadNum) {
    timeval tv_ = {0, 0};
    gettimeofday(&tv_, NULL);
    auto localTimePtr = std::localtime(&tv_.tv_sec);
    auto gmTimePtr = std::gmtime(&tv_.tv_sec);
    cout << "thread is " << threadNum << " localTimePtr is : " << localTimePtr << " gmTimePtr is " << gmTimePtr << endl;
}

int main()
{
    thread t1(fun, 1);
    t1.join();
    thread t2(fun, 2);
    t2.join();
    return 0;
}

You can find out that the thread1 and thread2 return same ptr.

thread is 1 localTimePtr is : 0x7ffff7d656a0 gmTimePtr is 0x7ffff7d656a0
thread is 2 localTimePtr is : 0x7ffff7d656a0 gmTimePtr is 0x7ffff7d656a0

And the solution is std::localtime to localtime_r and std::gmtime to gmtime_r

std::tm* minio::utils::Time::ToUTC() {
  std::tm* t = new std::tm;
  utc_ ? localtime_r(&tv_.tv_sec, t) : gmtime_r(&tv_.tv_sec, t);
  return t;
}
  • AccessDenied, SignatureDoesNotMatch condition:
    In BuildHeaders: use date ToAmzDate first.
void minio::s3::Request::BuildHeaders(http::Url& url,
                                      creds::Provider* provider) {
  headers.Add("Host", url.host);
  headers.Add("User-Agent", user_agent);

  bool md5sum_added = headers.Contains("Content-MD5");
  std::string md5sum;

  switch (method) {
    case http::Method::kPut:
    case http::Method::kPost:
      headers.Add("Content-Length", std::to_string(body.size()));
      if (!headers.Contains("Content-Type")) {
        headers.Add("Content-Type", "application/octet-stream");
      }
      if (provider != NULL) {
        sha256 = utils::Sha256Hash(body);
      } else if (!md5sum_added) {
        md5sum = utils::Md5sumHash(body);
      }
      break;
    default:
      if (provider != NULL) sha256 = EMPTY_SHA256;
  }

  if (!md5sum.empty()) headers.Add("Content-MD5", md5sum);
  if (!sha256.empty()) headers.Add("x-amz-content-sha256", sha256);

  date = utils::Time::Now();
  headers.Add("x-amz-date", date.ToAmzDate());

In SignV4S3](minio::signer::GetStringToSign): use the same date param ToAmzDate again

std::string minio::signer::GetStringToSign(
    utils::Time& date, std::string& scope,
    std::string& canonical_request_hash) {
  return "AWS4-HMAC-SHA256\n" + date.ToAmzDate() + "\n" + scope + "\n" +
         canonical_request_hash;
}

So it may cause the first AmzDataStr different from the second , although use same data.

  • RequestTimeTooSkewed condition:
    The ToAmaData may return another date‘s result which in another thread.

Compiling script reports errors in workspace

when I execute g++ ./examples/UploadObject.cc -I include -I build/vcpkg_installed/x64-linux/include -std=c++17

result is below like the picture
Selection_028

So how should I compile it?

how to corss-compile minio-cpp on ubuntu20.04 host for target aarch64 machine

How to cross-compile minio-cpp on host machine ubuntu20.04 with aarch64-linux-gnu?
I'm add

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_CROSSCOMPILING TRUE)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")

set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/aarch64-linux-gnu-g++")
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
set(CMAKE_INCLUDE_PATH /usr/aarch64-linux-gnu/include)
set(CMAKE_LIBRARY_PATH /usr/aarch64-linux-gnu/lib)
set(CMAKE_PROGRAM_PATH /usr/aarch64-linux-gnu/bin)

to

/minio-cpp/vcpkg-master/scripts/buildsystems/vcpkg.cmake

but without effective

potential stack buffer overflow

In http.h line 127 there is a sockaddr_in, which is an IPv4 sockaddr, but in the following line it gets filled with an IPv6 address, which needs more space than an IPv4 address
It should be sockaddr_in6 for that purpose.

Build without vckpg

For some reason I need to build my project without using vckpg, can you provide an example of how to use the minio without using vcpkg?

[help wanted]CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles"

System Info:
Edition Windows 10 IoT Enterprise LTSC
Version 21H2
Installed on ‎3/‎17/‎2023
OS build 19044.1288
Experience Windows Feature Experience Pack 120.2212.3920.0
image
Procedure:
git clone https://github.com/minio/minio-cpp
cd minio-cpp
wget --quiet -O vcpkg-master.zip https://github.com/microsoft/vcpkg/archive/refs/heads/master.zip
unzip -qq vcpkg-master.zip
./vcpkg-master/bootstrap-vcpkg.sh
./vcpkg-master/vcpkg integrate install
cmake -B ./build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=./vcpkg-master/scripts/buildsystems/vcpkg.cmake

Output Logs:
-- Running vcpkg install
-- Running vcpkg install - failed
CMake Error at vcpkg-master/scripts/buildsystems/vcpkg.cmake:892 (message):
vcpkg install failed. See logs for more information:
/tmp/minio-cpp/build/vcpkg-manifest-install.log
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:93 (include)
CMakeLists.txt:16 (project)

CMake Warning (dev) in vcpkg-master/scripts/buildsystems/vcpkg.cmake:
Policy CMP0011 is not set: Included scripts do automatic cmake_policy PUSH
and POP. Run "cmake --help-policy CMP0011" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.

The included script
/tmp/minio-cpp/vcpkg-master/scripts/buildsystems/vcpkg.cmake
affects policy settings. CMake is implying the NO_POLICY_SCOPE option for
compatibility, so the effects are applied to the including context.
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:93 (include)
CMakeLists.txt:16 (project)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

Any plans for C bindings ?

Hello,

I am reaching out in regards to support of C language, how viable is it in your opinion?
Are there any plans of having C SDK of minio or at least a header wrapper for C that will be linked to CXX library via minio-cpp?

Thank you !

Where is the header, client.h?

I use commands as follows build minio-cpp:

git clone https://github.com/minio/minio-cpp
cd minio-cpp
wget --quiet -O vcpkg-master.zip https://github.com/microsoft/vcpkg/archive/refs/heads/master.zip
unzip -qq vcpkg-master.zip
./vcpkg-master/bootstrap-vcpkg.sh
./vcpkg-master/vcpkg integrate install
cmake -B ./build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=./vcpkg-master/scripts/buildsystems/vcpkg.cmake
cmake --build ./build --config Debug

I got "DownloadObject.cc:1:10: fatal error: client.h: No such file or directory".

CMakeLists.txt

cmake_minimum_required(VERSION 3.27)
set(CMAKE_CXX_STANDARD 11)

find_package(PkgConfig REQUIRED)
find_package(CURL REQUIRED)
find_package(OpenSSL REQUIRED)

SET(requiredlibs)
list(APPEND requiredlibs stdc++fs)
list(APPEND requiredlibs CURL::libcurl)
list(APPEND requiredlibs OpenSSL::SSL OpenSSL::Crypto)

SET(S3_LIBS ${requiredlibs})

project(DownloadObject LANGUAGES CXX)
ADD_EXECUTABLE(${PROJECT_NAME} "DownloadObject.cc")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} miniocpp ${S3_LIBS})

DownloadObject.cc

#include "client.h"

int main(int argc, char* argv[]) {
  // Create S3 base URL.
  minio::s3::BaseUrl base_url("minio-api-endpoint");

  // Create credential provider.
  minio::creds::StaticProvider provider(
      "##########", "####################");

  // Create S3 client.
  minio::s3::Client client(base_url, &provider);

  // Create download object arguments.
  minio::s3::DownloadObjectArgs args;
  args.bucket = "minio-bucket";
  args.object = "test.py";
  args.filename = "downloaed-test.py";

  // Call download object.
  minio::s3::DownloadObjectResponse resp = client.DownloadObject(args);

  // Handle response.
  if (resp) {
    std::cout << "test.py is successfully downloaded to my-object.csv"
              << std::endl;
  } else {
    std::cout << "unable to download object; " << resp.Error().String()
              << std::endl;
  }

  return 0;
}
cmake -B ./build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=~/work-on-api/install-minio-cpp/minio-cpp/vcpkg-master/scripts/buildsystems/vcpkg.cmake

cmake --build ./build --config Debug

DownloadObject.cc:1:10: fatal error: client.h: No such file or directory

How do I set the timeout for minio-cpp?

When I use the UploadObject(args) function provided by minio-cpp to upload files, if there is a network failure, the program will be blocked and there is no opportunity to exit and correct the error. How do I set the timeout for minio-cpp? It seems that there are no settings related to timeout and network issues in minio-cpp.

segfault ListObjects if objects in bucket more then max_keys of 1000 keys

just replace 'i < 3' to 'i < 1010' in tests/tests.cc:390 at method test.ListObjects and you get it:
Program terminated with signal SIGSEGV, Segmentation fault.

#0  0x00007f65929e9241 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0  0x00007f65929e9241 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00007f65929e95fe in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
   from /lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x000055cf8340c963 in minio::s3::ListObjectsResult::Populate (this=0x7ffc43bd7000) at src/client.cc:38
#3  0x000055cf8339c738 in minio::s3::ListObjectsResult::operator++ (this=0x7ffc43bd7000) at include/client.h:49
#4  0x000055cf8339cced in minio::s3::ListObjectsResult::operator++ (this=0x7ffc43bd7000) at include/client.h:55
#5  0x000055cf833a328d in Tests::ListObjects (this=0x7ffc43bd7800, quantity=1010) at tests/tests.cc:406
#6  0x000055cf8339a08b in main (argc=1, argv=0x7ffc43bd7b18) at tests/tests.cc:724

Trouble at

sed -n "36,40p" src/client.cc

36    args_->marker = resp_.next_marker;
37  } else {
38    args_->start_after = resp_.start_after; // <- trouble at this line
39    args_->continuation_token = resp_.next_continuation_token;
40  }

The reason of trouble at src/client.cc:669:

minio::s3::ListObjectsResult minio::s3::Client::ListObjects(
    ListObjectsArgs args) {
   if (error::Error err = args.Validate()) return err;
  return ListObjectsResult(this, args);
 }

minio::s3::Client::ListObjects method accepts args as structure of ListObjectsArgs, then get its address and init ListObjectsResult with pointer to it. Then this pointer used again for each request at ListObjectsRsult.Populate() to continue list next part of objects at minio storage bucket.
But argument args in constructor ListObjects is not the original object, it is a copy of ListObjectsArgs created on function stack and pointer to this copy of object is transit to ListObjectsResult. Copy of object is destroyed on return from client.ListObjects. After that ListOjbectsResult in Populate() has freed pointer and when uses it this leads to segfault.

with openssl version error

with Debug has the exception:

  • Trying xxx:9722...
  • Connected to xxx (xxxx) port 9722 (#0)
  • ALPN: offers http/1.1
  • OpenSSL/3.1.0: error:0A00010B:SSL routines::wrong version number
  • Closing connection 0

i'm install minio-cpp with vcpkg install minio-cpp,

Use lib with cmakelist.txt

Hi, can sombody show me how to add this lib to cmakelist.txt
I tried both specified installtion, but i cant get it to work i always get a different error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.