├── .clang-format ├── .gitattributes ├── .github └── workflows │ ├── ci.yml │ └── linters.yml ├── .gitignore ├── CMakeLists.txt ├── CNAME ├── LICENSE ├── README.md ├── check-style.sh ├── check-version.py ├── configure.sh ├── docs ├── CNAME ├── Doxyfile.in └── README.md ├── examples ├── BucketExists.cc ├── ComposeObject.cc ├── CopyObject.cc ├── DeleteBucketEncryption.cc ├── DeleteBucketLifecycle.cc ├── DeleteBucketNotification.cc ├── DeleteBucketPolicy.cc ├── DeleteBucketReplication.cc ├── DeleteBucketTags.cc ├── DeleteObjectLockConfig.cc ├── DeleteObjectTags.cc ├── DisableObjectLegalHold.cc ├── DownloadObject.cc ├── EnableObjectLegalHold.cc ├── GetBucketEncryption.cc ├── GetBucketLifecycle.cc ├── GetBucketNotification.cc ├── GetBucketPolicy.cc ├── GetBucketReplication.cc ├── GetBucketTags.cc ├── GetBucketVersioning.cc ├── GetObject.cc ├── GetObjectLockConfig.cc ├── GetObjectProgress.cc ├── GetObjectRetention.cc ├── GetObjectTags.cc ├── GetPresignedObjectUrl.cc ├── GetPresignedPostFormData.cc ├── IsObjectLegalHoldEnabled.cc ├── ListBuckets.cc ├── ListObjects.cc ├── ListenBucketNotification.cc ├── MakeBucket.cc ├── PutObject.cc ├── PutObjectProgress.cc ├── RemoveBucket.cc ├── RemoveObject.cc ├── RemoveObjects.cc ├── SelectObjectContent.cc ├── SetBucketEncryption.cc ├── SetBucketLifecycle.cc ├── SetBucketNotification.cc ├── SetBucketPolicy.cc ├── SetBucketReplication.cc ├── SetBucketTags.cc ├── SetBucketVersioning.cc ├── SetObjectLockConfig.cc ├── SetObjectRetention.cc ├── SetObjectTags.cc ├── StatObject.cc └── UploadObject.cc ├── include └── miniocpp │ ├── args.h │ ├── baseclient.h │ ├── client.h │ ├── config.h │ ├── credentials.h │ ├── error.h │ ├── http.h │ ├── providers.h │ ├── request.h │ ├── response.h │ ├── select.h │ ├── signer.h │ ├── sse.h │ ├── types.h │ └── utils.h ├── miniocpp-config.cmake.in ├── miniocpp.pc.in ├── src ├── args.cc ├── baseclient.cc ├── client.cc ├── credentials.cc ├── error.cc ├── http.cc ├── providers.cc ├── request.cc ├── response.cc ├── select.cc ├── signer.cc ├── sse.cc ├── types.cc └── utils.cc ├── tests ├── private.key ├── public.crt └── tests.cc └── vcpkg.json /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: Google 3 | IndentWidth: 2 4 | --- 5 | Language: Cpp 6 | DerivePointerAlignment: false 7 | PointerAlignment: Left 8 | --- 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Declare files that will always have LF line endings on checkout. 5 | *.sh test eol=lf 6 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: MinIO C++ Cmake 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | # This ensures that previous jobs for the PR are canceled when the PR is 10 | # updated. 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.head_ref }} 13 | cancel-in-progress: true 14 | 15 | permissions: 16 | contents: read 17 | 18 | jobs: 19 | build: 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | config: 24 | - { 25 | name: "Ubuntu_Latest_GCC", 26 | os: ubuntu-latest, 27 | build_type: "Release", 28 | cc: "gcc", 29 | cxx: "g++" 30 | } 31 | - { 32 | name: "macOS Latest Clang", 33 | os: macos-latest, 34 | build_type: "Release", 35 | cc: "clang", 36 | cxx: "clang++" 37 | } 38 | - { 39 | name: "Windows Latest MSVC", 40 | os: windows-latest, 41 | build_type: "Release", 42 | cc: "cl", 43 | cxx: "cl" 44 | } 45 | 46 | name: ${{ matrix.config.name }} 47 | runs-on: ${{ matrix.config.os }} 48 | 49 | steps: 50 | - name: Checkout minio-cpp 51 | uses: actions/checkout@v4 52 | with: 53 | path: "minio-cpp" 54 | 55 | - name: Checkout vcpkg 56 | uses: actions/checkout@v4 57 | with: 58 | repository: microsoft/vcpkg 59 | path: "vcpkg" 60 | 61 | - name: Print env 62 | run: | 63 | echo github.event.action: ${{ github.event.action }} 64 | echo github.event_name: ${{ github.event_name }} 65 | 66 | - name: Install dependencies if Ubuntu 67 | if: startsWith(matrix.config.name, 'Ubuntu_Latest_GCC') 68 | run: | 69 | wget --quiet -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - 70 | echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-18 main' | sudo tee -a /etc/apt/sources.list 71 | sudo apt-get -qy update 72 | sudo apt-get -qy install cmake 73 | wget --quiet https://dl.min.io/server/minio/release/linux-amd64/minio 74 | chmod +x minio 75 | cmake --version 76 | ./minio --version 77 | 78 | - name: Install dependencies if macOS 79 | if: startsWith(matrix.config.os, 'macos') 80 | run: | 81 | brew install pkg-config cmake minio/stable/minio 82 | cmake --version 83 | minio --version 84 | 85 | - name: Install dependencies if Windows 86 | shell: bash 87 | if: startsWith(matrix.config.os, 'windows') 88 | run: | 89 | choco install -y --no-progress cmake wget 90 | wget --quiet https://dl.min.io/server/minio/release/windows-amd64/minio.exe 91 | chmod +x minio.exe 92 | cmake --version 93 | 94 | - name: Configure and Build 95 | shell: bash 96 | run: | 97 | ./vcpkg/bootstrap-vcpkg.sh 98 | cd minio-cpp 99 | ../vcpkg/vcpkg install 100 | cmake . -B ./build -DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DMINIO_CPP_TEST:BOOL=ON 101 | cmake --build ./build --config ${{matrix.config.build_type}} -j 4 102 | 103 | - name: Start MinIO server if Ubuntu 104 | if: startsWith(matrix.config.name, 'Ubuntu_Latest_GCC') 105 | run: | 106 | mkdir -p ~/.minio/certs 107 | cp ./minio-cpp/tests/public.crt ./minio-cpp/tests/private.key ~/.minio/certs/ 108 | sudo cp ./minio-cpp/tests/public.crt /usr/local/share/ca-certificates/ 109 | sudo update-ca-certificates 110 | MINIO_CI_CD=true ./minio server /tmp/test-xl/{1...4}/ & 111 | sleep 10 112 | 113 | - name: Start MinIO server if macOS 114 | if: startsWith(matrix.config.name, 'macos') 115 | run: | 116 | MINIO_CI_CD=true minio server test-xl/{1...4}/ & 117 | sleep 10 118 | 119 | - name: Start MinIO server if Windows 120 | if: startsWith(matrix.config.os, 'windows') 121 | shell: bash 122 | run: | 123 | mkdir -p ~/.minio/certs 124 | cp ./minio-cpp/tests/public.crt ./minio-cpp/tests/private.key ~/.minio/certs/ 125 | certutil -addstore -f "ROOT" ./minio-cpp/tests/public.crt 126 | MINIO_CI_CD=true ./minio.exe server test-xl/{1...4}/ & 127 | sleep 10 128 | 129 | - name: Run tests if Ubuntu 130 | if: startsWith(matrix.config.name, 'Ubuntu_Latest_GCC') 131 | run: | 132 | SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./minio-cpp/build/tests 133 | 134 | - name: Run tests if macOS 135 | if: startsWith(matrix.config.name, 'macos') 136 | run: | 137 | SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ./minio-cpp/build/tests 138 | 139 | - name: Run tests if Windows 140 | shell: bash 141 | if: startsWith(matrix.config.os, 'windows') 142 | run: | 143 | SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 ./minio-cpp/build/Release/tests.exe 144 | 145 | - name: Run CMake test 146 | run: | 147 | cd minio-cpp/build 148 | ctest -C ${{ matrix.config.build_type }} 149 | -------------------------------------------------------------------------------- /.github/workflows/linters.yml: -------------------------------------------------------------------------------- 1 | name: Linters 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | # This ensures that previous jobs for the PR are canceled when the PR is 10 | # updated. 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.head_ref }} 13 | cancel-in-progress: true 14 | 15 | permissions: 16 | contents: read 17 | 18 | jobs: 19 | coding-style: 20 | name: "Coding Style & Version Check" 21 | runs-on: ubuntu-24.04 22 | 23 | steps: 24 | - name: Checkout minio-cpp 25 | uses: actions/checkout@v4 26 | with: 27 | path: "minio-cpp" 28 | 29 | - name: "Python" 30 | uses: actions/setup-python@v5 31 | with: 32 | python-version: "3.x" 33 | 34 | - name: Install dependencies 35 | run: | 36 | sudo apt -qy install clang-format-18 37 | clang-format-18 --version 38 | 39 | - name: Version Check 40 | shell: bash 41 | working-directory: minio-cpp 42 | run: python check-version.py 43 | 44 | - name: Coding Style Check 45 | shell: bash 46 | working-directory: minio-cpp 47 | run: CLANG_FORMAT=clang-format-18 ./check-style.sh 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /vcpkg_installed 3 | /docs/search 4 | /docs/*html 5 | /docs/*png 6 | /docs/*js 7 | /docs/*css 8 | /docs/*svg 9 | /docs/*map 10 | /docs/*md5 11 | *.d 12 | s3tool 13 | *~ 14 | .vs 15 | CMakeSettings.json 16 | .idea/ 17 | vcpkg-master.zip 18 | vcpkg-master/ 19 | include/config.h 20 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | # Copyright 2021-2024 MinIO, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | # SPDX-License-Identifier: Apache-2.0 17 | 18 | cmake_minimum_required(VERSION 3.10) 19 | cmake_policy(SET CMP0091 NEW) 20 | 21 | # Minio C++ Project 22 | # ----------------- 23 | 24 | set(MINIO_CPP_MAJOR_VERSION "0") 25 | set(MINIO_CPP_MINOR_VERSION "3") 26 | set(MINIO_CPP_PATCH_VERSION "0") 27 | set(MINIO_CPP_VERSION_STRING "${MINIO_CPP_MAJOR_VERSION}.${MINIO_CPP_MINOR_VERSION}.${MINIO_CPP_PATCH_VERSION}") 28 | 29 | project(miniocpp 30 | DESCRIPTION "MinIO C++ Client SDK provides simple APIs to access S3 compatible object storage" 31 | VERSION ${MINIO_CPP_VERSION_STRING} 32 | LANGUAGES C CXX 33 | ) 34 | 35 | include(GNUInstallDirs) 36 | include(CheckIncludeFiles) 37 | include(CMakePackageConfigHelpers) 38 | 39 | option(MINIO_CPP_TEST "Build tests" OFF) 40 | option(MINIO_CPP_MAKE_DOC "Build documentation" OFF) 41 | 42 | set(MINIO_CPP_CFLAGS) 43 | set(MINIO_CPP_LIBS) 44 | set(MINIO_CPP_STD "17") 45 | 46 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") 47 | # MSVC 48 | else() 49 | # GCC/Clang/AppleClang/... 50 | LIST(APPEND MINIO_CPP_CFLAGS -Wall -Wextra -Wconversion) 51 | if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0 AND NOT MINGW) 52 | list(APPEND MINIO_CPP_LIBS stdc++fs) 53 | endif() 54 | endif() 55 | 56 | # Dependencies 57 | # ------------ 58 | 59 | find_package(OpenSSL REQUIRED) 60 | find_package(unofficial-curlpp CONFIG REQUIRED) 61 | find_package(unofficial-inih CONFIG REQUIRED) 62 | find_package(nlohmann_json CONFIG REQUIRED) 63 | find_package(pugixml CONFIG REQUIRED) 64 | find_package(ZLIB REQUIRED) 65 | 66 | list(APPEND MINIO_CPP_LIBS 67 | unofficial::curlpp::curlpp 68 | unofficial::inih::inireader 69 | nlohmann_json::nlohmann_json 70 | pugixml 71 | OpenSSL::SSL OpenSSL::Crypto 72 | ZLIB::ZLIB 73 | ) 74 | 75 | if (WIN32) 76 | list(APPEND MINIO_CPP_LIBS wsock32) 77 | list(APPEND MINIO_CPP_LIBS ws2_32) 78 | endif() 79 | 80 | # Minio C++ Library 81 | # ----------------- 82 | 83 | set(MINIO_CPP_SOURCES 84 | src/args.cc 85 | src/baseclient.cc 86 | src/client.cc 87 | src/credentials.cc 88 | src/error.cc 89 | src/http.cc 90 | src/providers.cc 91 | src/request.cc 92 | src/response.cc 93 | src/select.cc 94 | src/signer.cc 95 | src/sse.cc 96 | src/types.cc 97 | src/utils.cc 98 | ) 99 | 100 | set(MINIO_CPP_HEADERS 101 | include/miniocpp/args.h 102 | include/miniocpp/baseclient.h 103 | include/miniocpp/client.h 104 | include/miniocpp/config.h 105 | include/miniocpp/credentials.h 106 | include/miniocpp/error.h 107 | include/miniocpp/http.h 108 | include/miniocpp/providers.h 109 | include/miniocpp/request.h 110 | include/miniocpp/response.h 111 | include/miniocpp/select.h 112 | include/miniocpp/signer.h 113 | include/miniocpp/sse.h 114 | include/miniocpp/types.h 115 | include/miniocpp/utils.h 116 | ) 117 | 118 | option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) 119 | 120 | IF (BUILD_SHARED_LIBS) 121 | IF (WIN32) 122 | message(FATAL_ERROR "Unable to build shared library on Windows yet, this library lacks decorator support.") 123 | ELSE () 124 | add_library(miniocpp SHARED ${MINIO_CPP_SOURCES} ${MINIO_CPP_HEADERS}) 125 | ENDIF () 126 | ELSE () 127 | add_library(miniocpp STATIC ${MINIO_CPP_SOURCES} ${MINIO_CPP_HEADERS}) 128 | ENDIF () 129 | 130 | target_compile_options(miniocpp PRIVATE ${MINIO_CPP_CFLAGS}) 131 | target_compile_features(miniocpp PUBLIC cxx_std_${MINIO_CPP_STD}) 132 | target_include_directories(miniocpp PUBLIC 133 | $ 134 | $ 135 | ) 136 | target_link_libraries(miniocpp PUBLIC ${MINIO_CPP_LIBS}) 137 | set_target_properties(miniocpp PROPERTIES VERSION "${MINIO_CPP_VERSION_STRING}") 138 | set_target_properties(miniocpp PROPERTIES POSITION_INDEPENDENT_CODE ON) 139 | 140 | # Add a cmake alias - this is how users should use minio-cpp in their cmake projects. 141 | add_library(miniocpp::miniocpp ALIAS miniocpp) 142 | 143 | # Minio C++ Tests 144 | # --------------- 145 | 146 | if (MINIO_CPP_TEST) 147 | set(EXAMPLE_APPS 148 | MakeBucket 149 | RemoveBucket 150 | BucketExists 151 | ListBuckets 152 | StatObject 153 | RemoveObject 154 | DownloadObject 155 | UploadObject 156 | GetObject 157 | ListObjects 158 | PutObject 159 | CopyObject 160 | ComposeObject 161 | RemoveObjects 162 | SelectObjectContent 163 | ListenBucketNotification 164 | DeleteBucketPolicy 165 | GetBucketPolicy 166 | SetBucketPolicy 167 | DeleteBucketNotification 168 | GetBucketNotification 169 | SetBucketNotification 170 | DeleteBucketEncryption 171 | GetBucketEncryption 172 | SetBucketEncryption 173 | GetBucketVersioning 174 | SetBucketVersioning 175 | DeleteBucketReplication 176 | GetBucketReplication 177 | SetBucketReplication 178 | DeleteBucketLifecycle 179 | GetBucketLifecycle 180 | SetBucketLifecycle 181 | DeleteBucketTags 182 | GetBucketTags 183 | SetBucketTags 184 | DeleteObjectLockConfig 185 | GetObjectLockConfig 186 | SetObjectLockConfig 187 | DeleteObjectTags 188 | GetObjectTags 189 | SetObjectTags 190 | DisableObjectLegalHold 191 | EnableObjectLegalHold 192 | IsObjectLegalHoldEnabled 193 | GetObjectRetention 194 | SetObjectRetention 195 | GetPresignedObjectUrl 196 | GetPresignedPostFormData 197 | PutObjectProgress 198 | GetObjectProgress 199 | ) 200 | 201 | foreach(target ${EXAMPLE_APPS}) 202 | add_executable(${target} examples/${target}.cc) 203 | target_compile_features(${target} PUBLIC cxx_std_${MINIO_CPP_STD}) 204 | target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include) 205 | target_link_libraries(${target} PRIVATE miniocpp::miniocpp ${MINIO_CPP_LIBS}) 206 | endforeach() 207 | 208 | add_executable(tests tests/tests.cc) 209 | target_compile_features(tests PUBLIC cxx_std_${MINIO_CPP_STD}) 210 | target_include_directories(tests PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include) 211 | target_link_libraries(tests miniocpp ${MINIO_CPP_LIBS}) 212 | endif() 213 | 214 | # Minio C++ Documentation 215 | # ----------------------- 216 | 217 | if (MINIO_CPP_MAKE_DOC) 218 | # check if Doxygen is installed 219 | find_package(Doxygen) 220 | if (DOXYGEN_FOUND) 221 | # set input and output files 222 | set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in) 223 | set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) 224 | 225 | # request to configure the file 226 | configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) 227 | 228 | # note the option ALL which allows to build the docs together with the application 229 | add_custom_target(doc_doxygen ALL 230 | COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} 231 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 232 | COMMENT "Generating API documentation with Doxygen" 233 | VERBATIM ) 234 | else() 235 | message("Doxygen need to be installed to generate the doxygen documentation") 236 | endif() 237 | endif() 238 | 239 | # Installation Instructions 240 | # ------------------------- 241 | 242 | configure_package_config_file( 243 | "${CMAKE_CURRENT_SOURCE_DIR}/miniocpp-config.cmake.in" 244 | "${CMAKE_CURRENT_BINARY_DIR}/miniocpp-config.cmake" 245 | INSTALL_DESTINATION 246 | "{CMAKE_INSTALL_LIBDIR}/cmake/miniocpp" 247 | NO_SET_AND_CHECK_MACRO 248 | NO_CHECK_REQUIRED_COMPONENTS_MACRO 249 | ) 250 | 251 | install(TARGETS miniocpp 252 | EXPORT miniocpp-targets 253 | RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" 254 | ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" 255 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" 256 | INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") 257 | 258 | install(EXPORT miniocpp-targets 259 | NAMESPACE miniocpp:: 260 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/miniocpp" 261 | EXPORT_LINK_INTERFACE_LIBRARIES) 262 | 263 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/miniocpp-config.cmake" 264 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/miniocpp") 265 | 266 | install(FILES 267 | ${MINIO_CPP_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/miniocpp") 268 | 269 | configure_file(miniocpp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/miniocpp.pc @ONLY) 270 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/miniocpp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 271 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | minio-cpp.min.io -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MinIO C++ Client SDK for Amazon S3 Compatible Cloud Storage [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io) [![Sourcegraph](https://sourcegraph.com/github.com/minio/minio-cpp/-/badge.svg)](https://sourcegraph.com/github.com/minio/minio-cpp?badge) [![Apache V2 License](https://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/minio/minio-cpp/blob/master/LICENSE) 2 | 3 | MinIO C++ SDK is Simple Storage Service (aka S3) client to perform bucket and object operations to any Amazon S3 compatible object storage service. 4 | 5 | For a complete list of APIs and examples, please take a look at the [MinIO C++ Client API Reference](https://minio-cpp.min.io/) 6 | 7 | ## Build Requirements 8 | 9 | * [cmake](https://cmake.org/) 3.10 or higher. 10 | * [vcpkg](https://vcpkg.io/en/index.html) package manager. 11 | * A working C++ compiler that supports at least C++17. 12 | 13 | ## Installation via `vcpkg` 14 | 15 | MinIO C++ client SDK can be installed via `vcpkg` package manager: 16 | 17 | ```bash 18 | $ vcpkg install minio-cpp 19 | ``` 20 | 21 | Typically `minio-cpp` will be part of dependencies specified in `vcpkg.json` file: 22 | 23 | ```json 24 | { 25 | "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", 26 | "name": "your-project", 27 | "version": "0.0.1", 28 | "dependencies": [ 29 | { "name": "minio-cpp" } 30 | ] 31 | } 32 | ``` 33 | 34 | ## Using `minio-cpp` with cmake 35 | 36 | MinIO C++ cliend SDK can be consumed as a dependency in CMakeLists.txt, the following can be used as an example: 37 | 38 | ```cmake 39 | cmake_minimum_required(VERSION 3.10) 40 | 41 | project(miniocpp_example LANGUAGES C CXX) 42 | 43 | # This will try to find miniocpp package and all its dependencies. 44 | find_package(miniocpp REQUIRED) 45 | 46 | # Create an executable called miniocpp-example: 47 | add_executable(miniocpp-example example.cpp) 48 | 49 | # Link the executable to miniocpp and all its dependencies: 50 | target_link_libraries(miniocpp-example PRIVATE miniocpp::miniocpp) 51 | 52 | # Make sure you are using at least C++17: 53 | target_compile_features(miniocpp-example PUBLIC cxx_std_17) 54 | ``` 55 | 56 | Note that `miniocpp::miniocpp` is a cmake imported target, which contains all the instructions necessary to use `minio-cpp` library from your cmake projet file. 57 | 58 | ## Hacking minio-cpp 59 | 60 | In order to run minio-cpp tests and examples, you can do the following assuming `VCPKG_ROOT` points to a valid `vcpkg` installation: 61 | 62 | ```bash 63 | $ git clone https://github.com/minio/minio-cpp 64 | $ cd minio-cpp 65 | $ ${VCPKG_ROOT}/vcpkg install 66 | $ cmake . -B build/Debug -DCMAKE_BUILD_TYPE=Debug -DMINIO_CPP_TEST=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 67 | $ cmake --build ./build/Debug 68 | ``` 69 | 70 | Note that cmake also supports multi-configuration generators. Multi-configuration generators don't use `CMAKE_BUILD_TYPE` during configure time. For example a Visual Studio project can be setup the following way: 71 | 72 | ```bash 73 | $ git clone https://github.com/minio/minio-cpp 74 | $ cd minio-cpp 75 | $ ${VCPKG_ROOT}/vcpkg install 76 | $ cmake . -B build -DMINIO_CPP_TEST=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 77 | $ cmake --build ./build --config Debug 78 | ``` 79 | 80 | The examples above assumed that you have `vcpkg` already installed and you have a `VCPKG_ROOT` environment variable set. This is common if you use `vcpkg` to handle dependencies of multiple projects as only a single installation of `vcpkg` is required in that case. If you don't have `vcpkg` installed and you only want to use it to test `minio-cpp`, it's possible to install it locally like this: 81 | 82 | ```bash 83 | $ git clone https://github.com/minio/minio-cpp 84 | $ cd minio-cpp 85 | $ git clone https://github.com/microsoft/vcpkg.git 86 | $ ./vcpkg/bootstrap-vcpkg.sh 87 | $ ./vcpkg/vcpkg install 88 | $ cmake . -B ./build/Debug -DCMAKE_BUILD_TYPE=Debug -DMINIO_CPP_TEST=ON -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake 89 | $ cmake --build ./build/Debug 90 | ``` 91 | 92 | We recommend the setup with `VCPKG_ROOT` for development. In that case there is a `configure.sh` script, that can be used to create both Debug and Release projects: 93 | 94 | ```bash 95 | $ git clone https://github.com/minio/minio-cpp 96 | $ cd minio-cpp 97 | $ ./configure.sh -DMINIO_CPP_TEST=ON 98 | ``` 99 | 100 | ## Example:: file-uploader.cc 101 | 102 | ```c++ 103 | #include 104 | 105 | int main(int argc, char* argv[]) { 106 | // Create S3 base URL. 107 | minio::s3::BaseUrl base_url("play.min.io"); 108 | 109 | // Create credential provider. 110 | minio::creds::StaticProvider provider( 111 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 112 | 113 | // Create S3 client. 114 | minio::s3::Client client(base_url, &provider); 115 | std::string bucket_name = "asiatrip"; 116 | 117 | // Check 'asiatrip' bucket exist or not. 118 | bool exist; 119 | { 120 | minio::s3::BucketExistsArgs args; 121 | args.bucket = bucket_name; 122 | 123 | minio::s3::BucketExistsResponse resp = client.BucketExists(args); 124 | if (!resp) { 125 | std::cout << "unable to do bucket existence check; " << resp.Error() 126 | << std::endl; 127 | return EXIT_FAILURE; 128 | } 129 | 130 | exist = resp.exist; 131 | } 132 | 133 | // Make 'asiatrip' bucket if not exist. 134 | if (!exist) { 135 | minio::s3::MakeBucketArgs args; 136 | args.bucket = bucket_name; 137 | 138 | minio::s3::MakeBucketResponse resp = client.MakeBucket(args); 139 | if (!resp) { 140 | std::cout << "unable to create bucket; " << resp.Error() << std::endl; 141 | return EXIT_FAILURE; 142 | } 143 | } 144 | 145 | // Upload '/home/user/Photos/asiaphotos.zip' as object name 146 | // 'asiaphotos-2015.zip' to bucket 'asiatrip'. 147 | minio::s3::UploadObjectArgs args; 148 | args.bucket = bucket_name; 149 | args.object = "asiaphotos-2015.zip"; 150 | args.filename = "/home/user/Photos/asiaphotos.zip"; 151 | 152 | minio::s3::UploadObjectResponse resp = client.UploadObject(args); 153 | if (!resp) { 154 | std::cout << "unable to upload object; " << resp.Error() << std::endl; 155 | return EXIT_FAILURE; 156 | } 157 | 158 | std::cout << "'/home/user/Photos/asiaphotos.zip' is successfully uploaded as " 159 | << "object 'asiaphotos-2015.zip' to bucket 'asiatrip'." 160 | << std::endl; 161 | 162 | return EXIT_SUCCESS; 163 | } 164 | ``` 165 | 166 | ## License 167 | 168 | This SDK is distributed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0), see [LICENSE](https://github.com/minio/minio-cpp/blob/master/LICENSE) for more information. 169 | -------------------------------------------------------------------------------- /check-style.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "${CLANG_FORMAT}" ]; then 4 | CLANG_FORMAT="clang-format" 5 | fi 6 | 7 | function do_clang_format() { 8 | echo "verifying '${CLANG_FORMAT} --output-replacements-xml --style=Google $@'" 9 | if ${CLANG_FORMAT} --output-replacements-xml --style=Google "$@" | grep -q ' "$tmpfile" 19 | ec=0 20 | while read -r file; do 21 | if ! do_clang_format "$file"; then 22 | ec=255 23 | fi 24 | done < "$tmpfile" 25 | rm -f "$tmpfile" 26 | 27 | exit "$ec" 28 | -------------------------------------------------------------------------------- /check-version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # MinIO C++ Library for Amazon S3 Compatible Cloud Storage 4 | # Copyright 2022-2024 MinIO, Inc. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | 20 | import json 21 | import os 22 | import re 23 | import sys 24 | 25 | ROOT_PATH = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) 26 | 27 | def read_text_file(file_name): 28 | with open(file_name, "r", encoding="utf-8") as f: 29 | return f.read() 30 | 31 | def read_vcpkg_version(): 32 | package = json.loads(read_text_file(os.path.join(ROOT_PATH, "vcpkg.json"))) 33 | return package["version"] 34 | 35 | def read_cmake_version(): 36 | content = read_text_file(os.path.join(ROOT_PATH, "CMakeLists.txt")) 37 | 38 | major = re.search("set\\(MINIO_CPP_MAJOR_VERSION \"(\\d+)\"\\)", content) 39 | minor = re.search("set\\(MINIO_CPP_MINOR_VERSION \"(\\d+)\"\\)", content) 40 | patch = re.search("set\\(MINIO_CPP_PATCH_VERSION \"(\\d+)\"\\)", content) 41 | 42 | return "{}.{}.{}".format(major[1], minor[1], patch[1]) 43 | 44 | def read_source_version(): 45 | content = read_text_file(os.path.join(ROOT_PATH, "include", "miniocpp", "config.h")) 46 | 47 | major = re.search("#define MINIO_CPP_MAJOR_VERSION (\\d+)", content) 48 | minor = re.search("#define MINIO_CPP_MINOR_VERSION (\\d+)", content) 49 | patch = re.search("#define MINIO_CPP_PATCH_VERSION (\\d+)", content) 50 | 51 | return "{}.{}.{}".format(major[1], minor[1], patch[1]) 52 | 53 | def main(): 54 | vcpkg_version = read_vcpkg_version() 55 | cmake_version = read_cmake_version() 56 | source_version = read_source_version() 57 | 58 | if source_version == vcpkg_version and source_version == cmake_version: 59 | print("minio-cpp version {} is set correctly in all required files".format(source_version)) 60 | else: 61 | print("Versions don't match [source={} vcpkg={} cmake={}]\n".format(source_version, vcpkg_version, cmake_version)) 62 | print("When increasing a version, please make sure that all of the above have the same value!\n") 63 | print("Versions can be found in the following files:") 64 | print(" * include/miniocpp/config.h") 65 | print(" * CMakeLists.txt") 66 | print(" * vcpkg.json") 67 | sys.exit(1) 68 | 69 | if __name__ == "__main__": 70 | main() 71 | -------------------------------------------------------------------------------- /configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -x 4 | BUILD_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" 5 | 6 | if [ -n "$VCPKG_ROOT" ]; then 7 | BUILD_OPTIONS="${BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" 8 | fi 9 | 10 | echo "== [Configuring Build - Debug] ==" 11 | eval cmake . -B build/Debug -DCMAKE_BUILD_TYPE=Debug ${BUILD_OPTIONS} "$@" 12 | echo "" 13 | 14 | echo "== [Configuring Build - Release] ==" 15 | eval cmake . -B build/Release -DCMAKE_BUILD_TYPE=Release ${BUILD_OPTIONS} "$@" 16 | echo "" 17 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | minio-cpp.min.io -------------------------------------------------------------------------------- /docs/Doxyfile.in: -------------------------------------------------------------------------------- 1 | OUTPUT_DIRECTORY = @CMAKE_CURRENT_SOURCE_DIR@/docs 2 | INPUT = @CMAKE_CURRENT_SOURCE_DIR@/docs/README.md @CMAKE_CURRENT_SOURCE_DIR@/src @CMAKE_CURRENT_SOURCE_DIR@/include 3 | PROJECT_NAME = "MinIO C++ SDK" 4 | GENERATE_LATEX = NO 5 | WARN_IF_UNDOCUMENTED = NO 6 | USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_SOURCE_DIR@/docs/README.md 7 | HTML_OUTPUT = @CMAKE_CURRENT_SOURCE_DIR@/docs 8 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | > NOTE: This project is work in progress. 2 | 3 | MinIO C++ SDK is Simple Storage Service (aka S3) client to perform bucket and object operations to any Amazon S3 compatible object storage service. 4 | 5 | For a complete list of APIs and examples, please take a look at the [MinIO C++ Client API Reference](https://minio-cpp.min.io/) 6 | 7 | ## Build requirements 8 | * A working C++ development environment supporting C++17 standards. 9 | * CMake 3.10 or higher. 10 | * [vcpkg](https://vcpkg.io/en/index.html). 11 | 12 | ## Install from vcpkg 13 | ``` 14 | vcpkg install minio-cpp 15 | ``` 16 | 17 | ## Building source 18 | ``` 19 | $ git clone https://github.com/minio/minio-cpp 20 | $ cd minio-cpp 21 | $ wget --quiet -O vcpkg-master.zip https://github.com/microsoft/vcpkg/archive/refs/heads/master.zip 22 | $ unzip -qq vcpkg-master.zip 23 | $ ./vcpkg-master/bootstrap-vcpkg.sh 24 | $ ./vcpkg-master/vcpkg integrate install 25 | $ cmake -B ./build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=./vcpkg-master/scripts/buildsystems/vcpkg.cmake 26 | $ cmake --build ./build --config Debug 27 | ``` 28 | 29 | ## Example:: file-uploader.cc 30 | ``` 31 | #include 32 | 33 | int main(int argc, char* argv[]) { 34 | // Create S3 base URL. 35 | minio::http::BaseUrl base_url; 36 | base_url.SetHost("play.min.io"); 37 | 38 | // Create credential provider. 39 | minio::creds::StaticProvider provider( 40 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 41 | 42 | // Create S3 client. 43 | minio::s3::Client client(base_url, &provider); 44 | 45 | std::string bucket_name = "asiatrip"; 46 | 47 | // Check 'asiatrip' bucket exist or not. 48 | bool exist; 49 | { 50 | minio::s3::BucketExistsArgs args; 51 | args.bucket_ = bucket_name; 52 | 53 | minio::s3::BucketExistsResponse resp = client.BucketExists(args); 54 | if (!resp) { 55 | std::cout << "unable to do bucket existence check; " << resp.GetError() 56 | << std::endl; 57 | return EXIT_FAILURE; 58 | } 59 | 60 | exist = resp.exist_; 61 | } 62 | 63 | // Make 'asiatrip' bucket if not exist. 64 | if (!exist) { 65 | minio::s3::MakeBucketArgs args; 66 | args.bucket_ = bucket_name; 67 | 68 | minio::s3::MakeBucketResponse resp = client.MakeBucket(args); 69 | if (!resp) { 70 | std::cout << "unable to create bucket; " << resp.GetError() << std::endl; 71 | return EXIT_FAILURE; 72 | } 73 | } 74 | 75 | // Upload '/home/user/Photos/asiaphotos.zip' as object name 76 | // 'asiaphotos-2015.zip' to bucket 'asiatrip'. 77 | minio::s3::UploadObjectArgs args; 78 | args.bucket_ = bucket_name; 79 | args.object_ = "asiaphotos-2015.zip"; 80 | args.filename_ = "/home/user/Photos/asiaphotos.zip"; 81 | 82 | minio::s3::UploadObjectResponse resp = client.UploadObject(args); 83 | if (!resp) { 84 | std::cout << "unable to upload object; " << resp.GetError() << std::endl; 85 | return EXIT_FAILURE; 86 | } 87 | 88 | std::cout << "'/home/user/Photos/asiaphotos.zip' is successfully uploaded as " 89 | << "object 'asiaphotos-2015.zip' to bucket 'asiatrip'." 90 | << std::endl; 91 | 92 | return EXIT_SUCCESS; 93 | } 94 | ``` 95 | 96 | ## License 97 | This SDK is distributed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0), see [LICENSE](https://github.com/minio/minio-cpp/blob/master/LICENSE) for more information. 98 | -------------------------------------------------------------------------------- /examples/BucketExists.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create bucket exists arguments. 32 | minio::s3::BucketExistsArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call bucket exists. 36 | minio::s3::BucketExistsResponse resp = client.BucketExists(args); 37 | 38 | // Handle response. 39 | if (resp) { 40 | if (resp.exist) { 41 | std::cout << "my-bucket exists" << std::endl; 42 | } else { 43 | std::cout << "my-bucket does not exist" << std::endl; 44 | } 45 | } else { 46 | std::cout << "unable to do bucket existence check; " 47 | << resp.Error().String() << std::endl; 48 | } 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /examples/ComposeObject.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a compose of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create compose object arguments. 32 | minio::s3::ComposeObjectArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | std::list sources; 37 | 38 | minio::s3::ComposeSource source1; 39 | source1.bucket = "my-src-bucket1"; 40 | source1.object = "my-src-object1"; 41 | sources.push_back(source1); 42 | 43 | minio::s3::ComposeSource source2; 44 | source2.bucket = "my-src-bucket2"; 45 | source2.object = "my-src-object2"; 46 | sources.push_back(source2); 47 | 48 | args.sources = sources; 49 | 50 | // Call compose object. 51 | minio::s3::ComposeObjectResponse resp = client.ComposeObject(args); 52 | 53 | // Handle response. 54 | if (resp) { 55 | std::cout << "my-object is successfully created" << std::endl; 56 | } else { 57 | std::cout << "unable to compose object; " << resp.Error().String() 58 | << std::endl; 59 | } 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /examples/CopyObject.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create copy object arguments. 32 | minio::s3::CopyObjectArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | minio::s3::CopySource source; 37 | source.bucket = "my-src-bucket"; 38 | source.object = "my-src-object"; 39 | args.source = source; 40 | 41 | // Call copy object. 42 | minio::s3::CopyObjectResponse resp = client.CopyObject(args); 43 | 44 | // Handle response. 45 | if (resp) { 46 | std::cout << "my-object is successfully created from " 47 | << "my-src-bucket/my-src-object" << std::endl; 48 | } else { 49 | std::cout << "unable to do copy object; " << resp.Error().String() 50 | << std::endl; 51 | } 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /examples/DeleteBucketEncryption.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create delete bucket encryption arguments. 32 | minio::s3::DeleteBucketEncryptionArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call delete bucket encryption. 36 | minio::s3::DeleteBucketEncryptionResponse resp = 37 | client.DeleteBucketEncryption(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "bucket encryption of my-bucket is deleted successfully" 42 | << std::endl; 43 | } else { 44 | std::cout << "unable to delete bucket encryption; " << resp.Error().String() 45 | << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/DeleteBucketLifecycle.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create delete bucket lifecycle arguments. 32 | minio::s3::DeleteBucketLifecycleArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call delete bucket lifecycle. 36 | minio::s3::DeleteBucketLifecycleResponse resp = 37 | client.DeleteBucketLifecycle(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "bucket lifecycle of my-bucket is deleted successfully" 42 | << std::endl; 43 | } else { 44 | std::cout << "unable to delete bucket lifecycle; " << resp.Error().String() 45 | << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/DeleteBucketNotification.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create delete bucket notification arguments. 32 | minio::s3::DeleteBucketNotificationArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call delete bucket notification. 36 | minio::s3::DeleteBucketNotificationResponse resp = 37 | client.DeleteBucketNotification(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "bucket notification of my-bucket is deleted successfully" 42 | << std::endl; 43 | } else { 44 | std::cout << "unable to delete bucket notification; " 45 | << resp.Error().String() << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/DeleteBucketPolicy.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create delete bucket policy arguments. 32 | minio::s3::DeleteBucketPolicyArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call delete bucket policy. 36 | minio::s3::DeleteBucketPolicyResponse resp = client.DeleteBucketPolicy(args); 37 | 38 | // Handle response. 39 | if (resp) { 40 | std::cout << "bucket policy of my-bucket is deleted successfully" 41 | << std::endl; 42 | } else { 43 | std::cout << "unable to delete bucket policy; " << resp.Error().String() 44 | << std::endl; 45 | } 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /examples/DeleteBucketReplication.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create delete bucket encryption arguments. 32 | minio::s3::DeleteBucketEncryptionArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call delete bucket encryption. 36 | minio::s3::DeleteBucketEncryptionResponse resp = 37 | client.DeleteBucketEncryption(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "bucket encryption of my-bucket is deleted successfully" 42 | << std::endl; 43 | } else { 44 | std::cout << "unable to delete bucket encryption; " << resp.Error().String() 45 | << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/DeleteBucketTags.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create delete bucket tags arguments. 32 | minio::s3::DeleteBucketTagsArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call delete bucket tags. 36 | minio::s3::DeleteBucketTagsResponse resp = client.DeleteBucketTags(args); 37 | 38 | // Handle response. 39 | if (resp) { 40 | std::cout << "bucket tags of my-bucket is deleted successfully" 41 | << std::endl; 42 | } else { 43 | std::cout << "unable to delete bucket tags; " << resp.Error().String() 44 | << std::endl; 45 | } 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /examples/DeleteObjectLockConfig.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create delete object lock config arguments. 32 | minio::s3::DeleteObjectLockConfigArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call delete object lock config. 36 | minio::s3::DeleteObjectLockConfigResponse resp = 37 | client.DeleteObjectLockConfig(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "Object lock configuration is deleted successfully" 42 | << std::endl; 43 | } else { 44 | std::cout << "unable to delete object lock configuration; " 45 | << resp.Error().String() << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/DeleteObjectTags.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create delete object tags arguments. 32 | minio::s3::DeleteObjectTagsArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | // Call delete object tags. 37 | minio::s3::DeleteObjectTagsResponse resp = client.DeleteObjectTags(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "object tags of my-object is deleted successfully" 42 | << std::endl; 43 | } else { 44 | std::cout << "unable to delete object tags; " << resp.Error().String() 45 | << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/DisableObjectLegalHold.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create disable object legal hold arguments. 32 | minio::s3::DisableObjectLegalHoldArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | // Call disable object legal hold. 37 | minio::s3::DisableObjectLegalHoldResponse resp = 38 | client.DisableObjectLegalHold(args); 39 | 40 | // Handle response. 41 | if (resp) { 42 | std::cout << "legal hold on my-object is disabled successfully" 43 | << std::endl; 44 | } else { 45 | std::cout << "unable to disable object legal hold; " 46 | << resp.Error().String() << std::endl; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /examples/DownloadObject.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create download object arguments. 32 | minio::s3::DownloadObjectArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | args.filename = "my-object.csv"; 36 | 37 | // Call download object. 38 | minio::s3::DownloadObjectResponse resp = client.DownloadObject(args); 39 | 40 | // Handle response. 41 | if (resp) { 42 | std::cout << "my-object is successfully downloaded to my-object.csv" 43 | << std::endl; 44 | } else { 45 | std::cout << "unable to download object; " << resp.Error().String() 46 | << std::endl; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /examples/EnableObjectLegalHold.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create enable object legal hold arguments. 32 | minio::s3::EnableObjectLegalHoldArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | // Call enable object legal hold. 37 | minio::s3::EnableObjectLegalHoldResponse resp = 38 | client.EnableObjectLegalHold(args); 39 | 40 | // Handle response. 41 | if (resp) { 42 | std::cout << "legal hold on my-object is enabled successfully" << std::endl; 43 | } else { 44 | std::cout << "unable to enable object legal hold; " << resp.Error().String() 45 | << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/GetBucketEncryption.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get bucket encryption arguments. 32 | minio::s3::GetBucketEncryptionArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call get bucket encryption. 36 | minio::s3::GetBucketEncryptionResponse resp = 37 | client.GetBucketEncryption(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "SSE Algorithm: " << resp.config.sse_algorithm << std::endl; 42 | std::cout << "KMS Master Key ID: " << resp.config.kms_master_key_id 43 | << std::endl; 44 | } else { 45 | std::cout << "unable to get bucket encryption; " << resp.Error().String() 46 | << std::endl; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /examples/GetBucketLifecycle.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get bucket lifecycle arguments. 32 | minio::s3::GetBucketLifecycleArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call get bucket lifecycle. 36 | minio::s3::GetBucketLifecycleResponse resp = client.GetBucketLifecycle(args); 37 | 38 | // Handle response. 39 | if (resp) { 40 | std::cout << "Lifecycle configuration: " << resp.config.ToXML() 41 | << std::endl; 42 | } else { 43 | std::cout << "unable to get bucket lifecycle; " << resp.Error().String() 44 | << std::endl; 45 | } 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /examples/GetBucketNotification.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get bucket notification arguments. 32 | minio::s3::GetBucketNotificationArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call get bucket notification. 36 | minio::s3::GetBucketNotificationResponse resp = 37 | client.GetBucketNotification(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "Bucket notification: " << resp.config.ToXML() << std::endl; 42 | } else { 43 | std::cout << "unable to get bucket notification; " << resp.Error().String() 44 | << std::endl; 45 | } 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /examples/GetBucketPolicy.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get bucket policy arguments. 32 | minio::s3::GetBucketPolicyArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call get bucket policy. 36 | minio::s3::GetBucketPolicyResponse resp = client.GetBucketPolicy(args); 37 | 38 | // Handle response. 39 | if (resp) { 40 | std::cout << "Bucket policy: " << resp.policy << std::endl; 41 | } else { 42 | std::cout << "unable to get bucket policy; " << resp.Error().String() 43 | << std::endl; 44 | } 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /examples/GetBucketReplication.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get bucket encryption arguments. 32 | minio::s3::GetBucketEncryptionArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call get bucket encryption. 36 | minio::s3::GetBucketEncryptionResponse resp = 37 | client.GetBucketEncryption(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "SSE Algorithm: " << resp.config.sse_algorithm << std::endl; 42 | std::cout << "KMS Master Key ID: " << resp.config.kms_master_key_id 43 | << std::endl; 44 | } else { 45 | std::cout << "unable to get bucket encryption; " << resp.Error().String() 46 | << std::endl; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /examples/GetBucketTags.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get bucket tags arguments. 32 | minio::s3::GetBucketTagsArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call get bucket tags. 36 | minio::s3::GetBucketTagsResponse resp = client.GetBucketTags(args); 37 | 38 | // Handle response. 39 | if (resp) { 40 | std::cout << "Bucket tags: " << std::endl; 41 | for (auto& [key, value] : resp.tags) { 42 | std::cout << "Key: " << key << ", " << "Value: " << value << std::endl; 43 | } 44 | } else { 45 | std::cout << "unable to get bucket tags; " << resp.Error().String() 46 | << std::endl; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /examples/GetBucketVersioning.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get bucket versioning arguments. 32 | minio::s3::GetBucketVersioningArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call get bucket versioning. 36 | minio::s3::GetBucketVersioningResponse resp = 37 | client.GetBucketVersioning(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "Status: " << resp.Status() << std::endl; 42 | std::cout << "MFA Delete: " << resp.MfaDelete() << std::endl; 43 | } else { 44 | std::cout << "unable to get bucket versioning; " << resp.Error().String() 45 | << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/GetObject.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get object arguments. 32 | minio::s3::GetObjectArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | args.datafunc = [](minio::http::DataFunctionArgs args) -> bool { 36 | std::cout << args.datachunk; 37 | return true; 38 | }; 39 | 40 | // Call get object. 41 | minio::s3::GetObjectResponse resp = client.GetObject(args); 42 | 43 | // Handle response. 44 | if (resp) { 45 | std::cout << std::endl 46 | << "data of my-object is received successfully" << std::endl; 47 | } else { 48 | std::cout << "unable to get object; " << resp.Error().String() << std::endl; 49 | } 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /examples/GetObjectLockConfig.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get object lock config arguments. 32 | minio::s3::GetObjectLockConfigArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call get object lock config. 36 | minio::s3::GetObjectLockConfigResponse resp = 37 | client.GetObjectLockConfig(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "Object Lock Configuration:" << std::endl; 42 | if (minio::s3::IsRetentionModeValid(resp.config.retention_mode)) { 43 | std::cout << "Retention Mode: " 44 | << minio::s3::RetentionModeToString(resp.config.retention_mode) 45 | << std::endl; 46 | if (resp.config.retention_duration_days) { 47 | std::cout << "Retention Days: " << resp.config.retention_duration_days 48 | << std::endl; 49 | } 50 | if (resp.config.retention_duration_years) { 51 | std::cout << "Retention Years: " << resp.config.retention_duration_years 52 | << std::endl; 53 | } 54 | } 55 | } else { 56 | std::cout << "unable to get object lock configuration; " 57 | << resp.Error().String() << std::endl; 58 | } 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /examples/GetObjectProgress.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2023 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get object arguments. 32 | minio::s3::GetObjectArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | args.datafunc = [](minio::http::DataFunctionArgs args) -> bool { 36 | std::cout << "received data: " << args.datachunk.length() << " bytes" 37 | << std::endl; 38 | return true; 39 | }; 40 | args.progressfunc = [](minio::http::ProgressFunctionArgs args) -> bool { 41 | if (args.download_speed > 0) { 42 | std::cout << "downloaded speed: " << (long)args.download_speed << " bps" 43 | << std::endl; 44 | } else { 45 | std::cout << "downloaded: " << (long)args.downloaded_bytes << " bytes of " 46 | << (long)args.download_total_bytes << " bytes" << std::endl; 47 | } 48 | return true; 49 | }; 50 | 51 | // Call get object. 52 | minio::s3::GetObjectResponse resp = client.GetObject(args); 53 | 54 | // Handle response. 55 | if (resp) { 56 | std::cout << std::endl 57 | << "data of my-object is received successfully" << std::endl; 58 | } else { 59 | std::cout << "unable to get object; " << resp.Error().String() << std::endl; 60 | } 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /examples/GetObjectRetention.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get object retention arguments. 32 | minio::s3::GetObjectRetentionArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | // Call get object retention. 37 | minio::s3::GetObjectRetentionResponse resp = client.GetObjectRetention(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "Retention Mode: " 42 | << minio::s3::RetentionModeToString(resp.retention_mode) 43 | << std::endl; 44 | std::cout << "Retain Until Date: " 45 | << resp.retain_until_date.ToHttpHeaderValue() << std::endl; 46 | } else { 47 | std::cout << "unable to get object retention; " << resp.Error().String() 48 | << std::endl; 49 | } 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /examples/GetObjectTags.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get object tags arguments. 32 | minio::s3::GetObjectTagsArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | // Call get object tags. 37 | minio::s3::GetObjectTagsResponse resp = client.GetObjectTags(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "Object tags: " << std::endl; 42 | for (auto& [key, value] : resp.tags) { 43 | std::cout << "Key: " << key << ", " << "Value: " << value << std::endl; 44 | } 45 | } else { 46 | std::cout << "unable to get object tags; " << resp.Error().String() 47 | << std::endl; 48 | } 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /examples/GetPresignedObjectUrl.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get presigned object url arguments. 32 | minio::s3::GetPresignedObjectUrlArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | args.method = minio::http::Method::kGet; 36 | args.expiry_seconds = 60 * 60 * 24; // 1 day. 37 | 38 | // Call get presigned object url. 39 | minio::s3::GetPresignedObjectUrlResponse resp = 40 | client.GetPresignedObjectUrl(args); 41 | 42 | // Handle response. 43 | if (resp) { 44 | std::cout << "presigned URL to get object: " << resp.url << std::endl; 45 | } else { 46 | std::cout << "unable to get presigned object url; " << resp.Error().String() 47 | << std::endl; 48 | } 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /examples/GetPresignedPostFormData.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create get presigned post form data arguments. 32 | minio::utils::UtcTime expiration = minio::utils::UtcTime::Now(); 33 | expiration.Add(60 * 60 * 24); // 1 day from now. 34 | minio::s3::PostPolicy policy("my-bucket", expiration); 35 | policy.AddStartsWithCondition("key", "my/object/prefix/"); 36 | policy.AddContentLengthRangeCondition(1 * 1024 * 1024, 10 * 1024 * 1024); 37 | 38 | // Call get presigned post form data. 39 | minio::s3::GetPresignedPostFormDataResponse resp = 40 | client.GetPresignedPostFormData(policy); 41 | 42 | // Handle response. 43 | if (resp) { 44 | std::string fields; 45 | for (auto& [key, value] : resp.form_data) fields += key + "=" + value + " "; 46 | fields += "-F file=@"; 47 | std::cout << "Example CURL command to use form-data:" << std::endl 48 | << "curl -X POST https://play.min.io/my-bucket " << fields 49 | << std::endl; 50 | } else { 51 | std::cout << "unable to get presigned post form data; " 52 | << resp.Error().String() << std::endl; 53 | } 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /examples/IsObjectLegalHoldEnabled.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create is object legal hold enabled arguments. 32 | minio::s3::IsObjectLegalHoldEnabledArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | // Call is object legal hold enabled. 37 | minio::s3::IsObjectLegalHoldEnabledResponse resp = 38 | client.IsObjectLegalHoldEnabled(args); 39 | 40 | // Handle response. 41 | if (resp) { 42 | std::cout << "legal hold: " << (resp.enabled ? "ON" : "OFF") << std::endl; 43 | } else { 44 | std::cout << "unable to do is object legal hold enabled; " 45 | << resp.Error().String() << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/ListBuckets.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Call list buckets. 32 | minio::s3::ListBucketsResponse resp = client.ListBuckets(); 33 | 34 | // Handle response. 35 | if (resp) { 36 | for (auto& bucket : resp.buckets) { 37 | std::cout << "Bucket: " << bucket.name << "; Creation date: " 38 | << bucket.creation_date.ToHttpHeaderValue() << std::endl; 39 | } 40 | } else { 41 | std::cout << "unable to list buckets; " << resp.Error().String() 42 | << std::endl; 43 | } 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /examples/ListObjects.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create list objects arguments. 32 | minio::s3::ListObjectsArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call list objects. 36 | minio::s3::ListObjectsResult result = client.ListObjects(args); 37 | for (; result; result++) { 38 | minio::s3::Item item = *result; 39 | if (item) { 40 | std::cout << "Name: " << item.name << std::endl; 41 | std::cout << "Version ID: " << item.version_id << std::endl; 42 | std::cout << "ETag: " << item.etag << std::endl; 43 | std::cout << "Size: " << item.size << std::endl; 44 | std::cout << "Last Modified: " << item.last_modified << std::endl; 45 | std::cout << "Delete Marker: " 46 | << minio::utils::BoolToString(item.is_delete_marker) 47 | << std::endl; 48 | std::cout << "User Metadata: " << std::endl; 49 | for (auto& [key, value] : item.user_metadata) { 50 | std::cout << " " << key << ": " << value << std::endl; 51 | } 52 | std::cout << "Owner ID: " << item.owner_id << std::endl; 53 | std::cout << "Owner Name: " << item.owner_name << std::endl; 54 | std::cout << "Storage Class: " << item.storage_class << std::endl; 55 | std::cout << "Is Latest: " << minio::utils::BoolToString(item.is_latest) 56 | << std::endl; 57 | std::cout << "Is Prefix: " << minio::utils::BoolToString(item.is_prefix) 58 | << std::endl; 59 | std::cout << "---" << std::endl; 60 | } else { 61 | std::cout << "unable to listobjects; " << item.Error().String() 62 | << std::endl; 63 | break; 64 | } 65 | } 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /examples/ListenBucketNotification.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create listen bucket notification arguments. 32 | minio::s3::ListenBucketNotificationArgs args; 33 | args.bucket = "my-bucket"; 34 | args.func = [](std::list records) -> bool { 35 | for (auto& record : records) { 36 | std::cout << "Received: Event: " << record.event_name << ", " 37 | << "Bucket: " << record.s3.bucket.name << ", " 38 | << "Object: " << record.s3.object.key << std::endl; 39 | } 40 | return true; 41 | }; 42 | 43 | // Call listen bucket notification. 44 | minio::s3::ListenBucketNotificationResponse resp = 45 | client.ListenBucketNotification(args); 46 | 47 | // Handle response. 48 | if (!resp) { 49 | std::cout << "unable to do listen bucket notification; " 50 | << resp.Error().String() << std::endl; 51 | } 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /examples/MakeBucket.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create make bucket arguments. 32 | minio::s3::MakeBucketArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call make bucket. 36 | minio::s3::MakeBucketResponse resp = client.MakeBucket(args); 37 | 38 | // Handle response. 39 | if (resp) { 40 | std::cout << "my-bucket is created successfully" << std::endl; 41 | } else { 42 | std::cout << "unable to create bucket; " << resp.Error().String() 43 | << std::endl; 44 | } 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /examples/PutObject.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int main() { 30 | // Create S3 base URL. 31 | minio::s3::BaseUrl base_url("play.min.io"); 32 | 33 | // Create credential provider. 34 | minio::creds::StaticProvider provider( 35 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 36 | 37 | // Create S3 client. 38 | minio::s3::Client client(base_url, &provider); 39 | 40 | // Create put object arguments. 41 | std::ifstream file("my-object.csv"); 42 | 43 | minio::s3::PutObjectArgs args(file, 47615315, 0); 44 | args.bucket = "my-bucket"; 45 | args.object = "my-object"; 46 | 47 | // Call put object. 48 | minio::s3::PutObjectResponse resp = client.PutObject(args); 49 | 50 | // Handle response. 51 | if (resp) { 52 | std::cout << "my-object is successfully created" << std::endl; 53 | } else { 54 | std::cout << "unable to do put object; " << resp.Error().String() 55 | << std::endl; 56 | } 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /examples/PutObjectProgress.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2023 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int main() { 30 | // Create S3 base URL. 31 | minio::s3::BaseUrl base_url("play.min.io"); 32 | 33 | // Create credential provider. 34 | minio::creds::StaticProvider provider( 35 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 36 | 37 | // Create S3 client. 38 | minio::s3::Client client(base_url, &provider); 39 | 40 | // Create put object arguments. 41 | std::ifstream file("my-object.csv"); 42 | 43 | minio::s3::PutObjectArgs args(file, 47615315, 15728640); 44 | args.bucket = "my-bucket"; 45 | args.object = "my-object"; 46 | args.progressfunc = [](minio::http::ProgressFunctionArgs args) -> bool { 47 | if (args.upload_speed > 0) { 48 | std::cout << "uploaded speed: " << (long)args.upload_speed << " bps" 49 | << std::endl; 50 | } else { 51 | std::cout << "uploaded: " << (long)args.uploaded_bytes << " bytes of " 52 | << (long)args.upload_total_bytes << " bytes" << std::endl; 53 | } 54 | return true; 55 | }; 56 | 57 | // Call put object. 58 | minio::s3::PutObjectResponse resp = client.PutObject(args); 59 | 60 | // Handle response. 61 | if (resp) { 62 | std::cout << "my-object is successfully created" << std::endl; 63 | } else { 64 | std::cout << "unable to do put object; " << resp.Error().String() 65 | << std::endl; 66 | } 67 | 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /examples/RemoveBucket.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create remove bucket arguments. 32 | minio::s3::RemoveBucketArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | // Call remove bucket. 36 | minio::s3::RemoveBucketResponse resp = client.RemoveBucket(args); 37 | 38 | // Handle response. 39 | if (resp) { 40 | std::cout << "my-bucket is removed successfully" << std::endl; 41 | } else { 42 | std::cout << "unable to remove bucket; " << resp.Error().String() 43 | << std::endl; 44 | } 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /examples/RemoveObject.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create remove object arguments. 32 | minio::s3::RemoveObjectArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | // Call remove object. 37 | minio::s3::RemoveObjectResponse resp = client.RemoveObject(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "my-object is removed successfully" << std::endl; 42 | } else { 43 | std::cout << "unable to remove object; " << resp.Error().String() 44 | << std::endl; 45 | } 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /examples/RemoveObjects.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create remove object arguments. 32 | minio::s3::RemoveObjectsArgs args; 33 | args.bucket = "my-bucket"; 34 | 35 | std::list objects; 36 | objects.push_back(minio::s3::DeleteObject{"my-object1"}); 37 | objects.push_back(minio::s3::DeleteObject{"my-object2"}); 38 | objects.push_back(minio::s3::DeleteObject{"my-object3"}); 39 | std::list::iterator i = objects.begin(); 40 | 41 | args.func = [&objects = objects, 42 | &i = i](minio::s3::DeleteObject& obj) -> bool { 43 | if (i == objects.end()) return false; 44 | obj = *i; 45 | i++; 46 | return true; 47 | }; 48 | 49 | // Call remove objects. 50 | minio::s3::RemoveObjectsResult result = client.RemoveObjects(args); 51 | for (; result; result++) { 52 | minio::s3::DeleteError err = *result; 53 | if (!err) { 54 | std::cout << "unable to do remove objects; " << err.Error().String() 55 | << std::endl; 56 | break; 57 | } 58 | 59 | std::cout << "unable to remove object " << err.object_name; 60 | if (!err.version_id.empty()) { 61 | std::cout << " of version ID " << err.version_id; 62 | } 63 | std::cout << std::endl; 64 | } 65 | 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /examples/SelectObjectContent.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | #include 20 | 21 | int main() { 22 | // Create S3 base URL. 23 | minio::s3::BaseUrl base_url("play.min.io"); 24 | 25 | // Create credential provider. 26 | minio::creds::StaticProvider provider( 27 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 28 | 29 | // Create S3 client. 30 | minio::s3::Client client(base_url, &provider); 31 | 32 | std::string expression = "select * from S3Object"; 33 | minio::s3::CsvInputSerialization csv_input; 34 | minio::s3::FileHeaderInfo file_header_info = minio::s3::FileHeaderInfo::kUse; 35 | csv_input.file_header_info = &file_header_info; 36 | minio::s3::CsvOutputSerialization csv_output; 37 | minio::s3::QuoteFields quote_fields = minio::s3::QuoteFields::kAsNeeded; 38 | csv_output.quote_fields = "e_fields; 39 | minio::s3::SelectRequest request(expression, &csv_input, &csv_output); 40 | 41 | std::string records; 42 | auto func = [&records = records](minio::s3::SelectResult result) -> bool { 43 | if (result.err) { 44 | std::cout << "error occurred; " << result.err.String() << std::endl; 45 | return false; 46 | } 47 | records += result.records; 48 | return true; 49 | }; 50 | 51 | minio::s3::SelectObjectContentArgs args(request, func); 52 | args.bucket = "my-bucket"; 53 | args.object = "my-object.csv"; 54 | minio::s3::SelectObjectContentResponse resp = 55 | client.SelectObjectContent(args); 56 | if (resp) { 57 | std::cout << "records retrieved" << std::endl; 58 | std::cout << records << std::endl; 59 | } else { 60 | std::cout << "unable to do select object content; " << resp.Error().String() 61 | << std::endl; 62 | } 63 | 64 | return 0; 65 | } 66 | -------------------------------------------------------------------------------- /examples/SetBucketEncryption.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create set bucket encryption arguments. 32 | minio::s3::SseConfig sseS3Config = minio::s3::SseConfig::S3(); 33 | minio::s3::SetBucketEncryptionArgs args(sseS3Config); 34 | args.bucket = "my-bucket"; 35 | 36 | // Call set bucket encryption. 37 | minio::s3::SetBucketEncryptionResponse resp = 38 | client.SetBucketEncryption(args); 39 | 40 | // Handle response. 41 | if (resp) { 42 | std::cout << "Bucket encryption is set successfully" << std::endl; 43 | } else { 44 | std::cout << "unable to set bucket encryption; " << resp.Error().String() 45 | << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/SetBucketLifecycle.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create set bucket lifecycle arguments. 32 | minio::s3::LifecycleConfig config; 33 | { 34 | minio::s3::LifecycleRule rule; 35 | rule.id = "rule1"; 36 | rule.status = true; 37 | rule.transition_days = minio::s3::Integer(30); 38 | rule.transition_storage_class = "GLACIER"; 39 | rule.filter.prefix = minio::s3::Prefix("documents/"); 40 | config.rules.push_back(rule); 41 | } 42 | { 43 | minio::s3::LifecycleRule rule; 44 | rule.id = "rule2"; 45 | rule.status = true; 46 | rule.expiration_days = minio::s3::Integer(365); 47 | rule.filter.prefix = minio::s3::Prefix("logs/"); 48 | config.rules.push_back(rule); 49 | } 50 | 51 | minio::s3::SetBucketLifecycleArgs args(config); 52 | args.bucket = "my-bucket"; 53 | 54 | // Call set bucket lifecycle. 55 | minio::s3::SetBucketLifecycleResponse resp = client.SetBucketLifecycle(args); 56 | 57 | // Handle response. 58 | if (resp) { 59 | std::cout << "Bucket lifecycle is set successfully" << std::endl; 60 | } else { 61 | std::cout << "unable to set bucket lifecycle; " << resp.Error().String() 62 | << std::endl; 63 | } 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /examples/SetBucketNotification.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | minio::s3::QueueConfig qconfig; 32 | qconfig.queue = "QUEUE-ARN-OF-THIS-BUCKET"; 33 | qconfig.events.push_back("s3:ObjectCreated:*"); 34 | qconfig.id = "1"; 35 | qconfig.prefix_filter_rule = minio::s3::PrefixFilterRule("abc"); 36 | minio::s3::NotificationConfig config; 37 | config.queue_config_list.push_back(qconfig); 38 | 39 | // Create set bucket notification arguments. 40 | minio::s3::SetBucketNotificationArgs args(config); 41 | args.bucket = "my-bucket"; 42 | 43 | // Call set bucket notification. 44 | minio::s3::SetBucketNotificationResponse resp = 45 | client.SetBucketNotification(args); 46 | 47 | // Handle response. 48 | if (resp) { 49 | std::cout << "Bucket notification is set successfully" << std::endl; 50 | } else { 51 | std::cout << "unable to set bucket notification; " << resp.Error().String() 52 | << std::endl; 53 | } 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /examples/SetBucketPolicy.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create set bucket policy arguments. 32 | minio::s3::SetBucketPolicyArgs args; 33 | args.bucket = "my-bucket"; 34 | args.policy = 35 | "{" 36 | " \"Version\": \"2012-10-17\"," 37 | " \"Statement\": [" 38 | " {" 39 | " \"Action\": [" 40 | " \"s3:*\"" 41 | " ]," 42 | " \"Effect\": \"Allow\"," 43 | " \"Resource\": [" 44 | " \"arn:aws:s3:::*\"" 45 | " ]," 46 | " \"Sid\": \"\"" 47 | " }" 48 | " ]" 49 | "}"; 50 | 51 | // Call set bucket policy. 52 | minio::s3::SetBucketPolicyResponse resp = client.SetBucketPolicy(args); 53 | 54 | // Handle response. 55 | if (resp) { 56 | std::cout << "Bucket policy is set successfully" << std::endl; 57 | } else { 58 | std::cout << "unable to set bucket policy; " << resp.Error().String() 59 | << std::endl; 60 | } 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /examples/SetBucketReplication.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create set bucket replication arguments. 32 | minio::s3::ReplicationRule rule; 33 | rule.id = "rule1"; 34 | rule.status = true; 35 | rule.priority = 1; 36 | rule.delete_marker_replication_status = false; 37 | rule.destination.bucket_arn = "REPLACE-WITH-ACTUAL-DESTINATION-BUCKET-ARN"; 38 | rule.filter.and_operator.prefix = minio::s3::Prefix("TaxDocs"); 39 | rule.filter.and_operator.tags["key1"] = "value1"; 40 | rule.filter.and_operator.tags["key2"] = "value2"; 41 | 42 | minio::s3::ReplicationConfig config; 43 | config.role = "REPLACE-WITH-ACTUAL-ROLE"; 44 | config.rules.push_back(rule); 45 | 46 | minio::s3::SetBucketReplicationArgs args(config); 47 | args.bucket = "my-bucket"; 48 | 49 | // Call set bucket replication. 50 | minio::s3::SetBucketReplicationResponse resp = 51 | client.SetBucketReplication(args); 52 | 53 | // Handle response. 54 | if (resp) { 55 | std::cout << "Bucket replication is set successfully" << std::endl; 56 | } else { 57 | std::cout << "unable to set bucket replication; " << resp.Error().String() 58 | << std::endl; 59 | } 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /examples/SetBucketTags.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create set bucket tags arguments. 32 | minio::s3::SetBucketTagsArgs args; 33 | args.bucket = "my-bucket"; 34 | args.tags["Project"] = "Project One"; 35 | args.tags["User"] = "jsmith"; 36 | 37 | // Call set bucket tags. 38 | minio::s3::SetBucketTagsResponse resp = client.SetBucketTags(args); 39 | 40 | // Handle response. 41 | if (resp) { 42 | std::cout << "Bucket tags are set successfully" << std::endl; 43 | } else { 44 | std::cout << "unable to set bucket tags; " << resp.Error().String() 45 | << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/SetBucketVersioning.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create set bucket versioning arguments. 32 | minio::s3::SetBucketVersioningArgs args; 33 | args.bucket = "my-bucket"; 34 | args.status = true; 35 | 36 | // Call set bucket versioning. 37 | minio::s3::SetBucketVersioningResponse resp = 38 | client.SetBucketVersioning(args); 39 | 40 | // Handle response. 41 | if (resp) { 42 | std::cout << "Bucket versioning is enabled successfully" << std::endl; 43 | } else { 44 | std::cout << "unable to set bucket versioning; " << resp.Error().String() 45 | << std::endl; 46 | } 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /examples/SetObjectLockConfig.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create set object lock config arguments. 32 | minio::s3::SetObjectLockConfigArgs args; 33 | args.bucket = "my-bucket"; 34 | args.config.retention_mode = minio::s3::RetentionMode::kGovernance; 35 | args.config.retention_duration_days = minio::s3::Integer(30); 36 | 37 | // Call set object lock config. 38 | minio::s3::SetObjectLockConfigResponse resp = 39 | client.SetObjectLockConfig(args); 40 | 41 | // Handle response. 42 | if (resp) { 43 | std::cout << "Object lock configuration is set successfully" << std::endl; 44 | } else { 45 | std::cout << "unable to do object lock configuration; " 46 | << resp.Error().String() << std::endl; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /examples/SetObjectRetention.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create set object retention arguments. 32 | minio::s3::SetObjectRetentionArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | args.retention_mode = minio::s3::RetentionMode::kGovernance; 36 | minio::utils::UtcTime tomorrow = minio::utils::UtcTime::Now(); 37 | tomorrow.Add(60 * 60 * 24); 38 | args.retain_until_date = tomorrow; 39 | 40 | // Call set object retention. 41 | minio::s3::SetObjectRetentionResponse resp = client.SetObjectRetention(args); 42 | 43 | // Handle response. 44 | if (resp) { 45 | std::cout << "Object retention are set successfully" << std::endl; 46 | } else { 47 | std::cout << "unable to set object retention; " << resp.Error().String() 48 | << std::endl; 49 | } 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /examples/SetObjectTags.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create set object tags arguments. 32 | minio::s3::SetObjectTagsArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | args.tags["Project"] = "Project One"; 36 | args.tags["User"] = "jsmith"; 37 | 38 | // Call set object tags. 39 | minio::s3::SetObjectTagsResponse resp = client.SetObjectTags(args); 40 | 41 | // Handle response. 42 | if (resp) { 43 | std::cout << "Object tags are set successfully" << std::endl; 44 | } else { 45 | std::cout << "unable to set object tags; " << resp.Error().String() 46 | << std::endl; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /examples/StatObject.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create stat object arguments. 32 | minio::s3::StatObjectArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | 36 | // Call stat object. 37 | minio::s3::StatObjectResponse resp = client.StatObject(args); 38 | 39 | // Handle response. 40 | if (resp) { 41 | std::cout << "Version ID: " << resp.version_id << std::endl; 42 | std::cout << "ETag: " << resp.etag << std::endl; 43 | std::cout << "Size: " << resp.size << std::endl; 44 | std::cout << "Last Modified: " << resp.last_modified << std::endl; 45 | std::cout << "Retention Mode: "; 46 | if (minio::s3::IsRetentionModeValid(resp.retention_mode)) { 47 | std::cout << minio::s3::RetentionModeToString(resp.retention_mode) 48 | << std::endl; 49 | } else { 50 | std::cout << "-" << std::endl; 51 | } 52 | std::cout << "Retention Retain Until Date: "; 53 | if (resp.retention_retain_until_date) { 54 | std::cout << resp.retention_retain_until_date.ToHttpHeaderValue() 55 | << std::endl; 56 | } else { 57 | std::cout << "-" << std::endl; 58 | } 59 | std::cout << "Legal Hold: "; 60 | if (minio::s3::IsLegalHoldValid(resp.legal_hold)) { 61 | std::cout << minio::s3::LegalHoldToString(resp.legal_hold) << std::endl; 62 | } else { 63 | std::cout << "-" << std::endl; 64 | } 65 | std::cout << "Delete Marker: " 66 | << minio::utils::BoolToString(resp.delete_marker) << std::endl; 67 | std::cout << "User Metadata: " << std::endl; 68 | std::list keys = resp.user_metadata.Keys(); 69 | for (auto& key : keys) { 70 | std::cout << " " << key << ": " << resp.user_metadata.GetFront(key) 71 | << std::endl; 72 | } 73 | } else { 74 | std::cout << "unable to get stat object; " << resp.Error().String() 75 | << std::endl; 76 | } 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /examples/UploadObject.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include 19 | 20 | int main() { 21 | // Create S3 base URL. 22 | minio::s3::BaseUrl base_url("play.min.io"); 23 | 24 | // Create credential provider. 25 | minio::creds::StaticProvider provider( 26 | "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"); 27 | 28 | // Create S3 client. 29 | minio::s3::Client client(base_url, &provider); 30 | 31 | // Create upload object arguments. 32 | minio::s3::UploadObjectArgs args; 33 | args.bucket = "my-bucket"; 34 | args.object = "my-object"; 35 | args.filename = "my-object.csv"; 36 | 37 | // Call upload object. 38 | minio::s3::UploadObjectResponse resp = client.UploadObject(args); 39 | 40 | // Handle response. 41 | if (resp) { 42 | std::cout << "my-object.csv is successfully uploaded to my-object" 43 | << std::endl; 44 | } else { 45 | std::cout << "unable to upload object; " << resp.Error().String() 46 | << std::endl; 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /include/miniocpp/baseclient.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_BASECLIENT_H_INCLUDED 19 | #define MINIO_CPP_BASECLIENT_H_INCLUDED 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "args.h" 26 | #include "config.h" 27 | #include "error.h" 28 | #include "http.h" 29 | #include "providers.h" 30 | #include "request.h" 31 | #include "response.h" 32 | #include "utils.h" 33 | 34 | #if defined(_WIN32) && defined(GetObject) 35 | #pragma push_macro("GetObject") 36 | #undef GetObject 37 | #define MINIO_CPP_GET_OBJECT_DEFINED 38 | #endif 39 | 40 | namespace minio::s3 { 41 | 42 | utils::Multimap GetCommonListObjectsQueryParams( 43 | const std::string& delimiter, const std::string& encoding_type, 44 | unsigned int max_keys, const std::string& prefix); 45 | 46 | /** 47 | * Base client to perform S3 APIs. 48 | */ 49 | class BaseClient { 50 | protected: 51 | BaseUrl base_url_; 52 | creds::Provider* const provider_ = nullptr; 53 | std::map region_map_; 54 | bool debug_ = false; 55 | bool ignore_cert_check_ = false; 56 | std::string ssl_cert_file_; 57 | std::string user_agent_ = DEFAULT_USER_AGENT; 58 | 59 | public: 60 | explicit BaseClient(BaseUrl base_url, 61 | creds::Provider* const provider = nullptr); 62 | 63 | virtual ~BaseClient() = default; 64 | 65 | void Debug(bool flag) { debug_ = flag; } 66 | 67 | void IgnoreCertCheck(bool flag) { ignore_cert_check_ = flag; } 68 | 69 | void SetSslCertFile(std::string ssl_cert_file) { 70 | ssl_cert_file_ = std::move(ssl_cert_file); 71 | } 72 | 73 | error::Error SetAppInfo(std::string_view app_name, 74 | std::string_view app_version); 75 | 76 | void HandleRedirectResponse(std::string& code, std::string& message, 77 | int status_code, http::Method method, 78 | const utils::Multimap& headers, 79 | const std::string& bucket_name, 80 | bool retry = false); 81 | Response GetErrorResponse(http::Response resp, std::string_view resource, 82 | http::Method method, const std::string& bucket_name, 83 | const std::string& object_name); 84 | Response execute(Request& req); 85 | Response Execute(Request& req); 86 | GetRegionResponse GetRegion(const std::string& bucket_name, 87 | const std::string& region); 88 | 89 | AbortMultipartUploadResponse AbortMultipartUpload( 90 | AbortMultipartUploadArgs args); 91 | BucketExistsResponse BucketExists(BucketExistsArgs args); 92 | CompleteMultipartUploadResponse CompleteMultipartUpload( 93 | CompleteMultipartUploadArgs args); 94 | CreateMultipartUploadResponse CreateMultipartUpload( 95 | CreateMultipartUploadArgs args); 96 | DeleteBucketEncryptionResponse DeleteBucketEncryption( 97 | DeleteBucketEncryptionArgs args); 98 | DisableObjectLegalHoldResponse DisableObjectLegalHold( 99 | DisableObjectLegalHoldArgs args); 100 | DeleteBucketLifecycleResponse DeleteBucketLifecycle( 101 | DeleteBucketLifecycleArgs args); 102 | DeleteBucketNotificationResponse DeleteBucketNotification( 103 | DeleteBucketNotificationArgs args); 104 | DeleteBucketPolicyResponse DeleteBucketPolicy(DeleteBucketPolicyArgs args); 105 | DeleteBucketReplicationResponse DeleteBucketReplication( 106 | DeleteBucketReplicationArgs args); 107 | DeleteBucketTagsResponse DeleteBucketTags(DeleteBucketTagsArgs args); 108 | DeleteObjectLockConfigResponse DeleteObjectLockConfig( 109 | DeleteObjectLockConfigArgs args); 110 | DeleteObjectTagsResponse DeleteObjectTags(DeleteObjectTagsArgs args); 111 | EnableObjectLegalHoldResponse EnableObjectLegalHold( 112 | EnableObjectLegalHoldArgs args); 113 | GetBucketEncryptionResponse GetBucketEncryption(GetBucketEncryptionArgs args); 114 | GetBucketLifecycleResponse GetBucketLifecycle(GetBucketLifecycleArgs args); 115 | GetBucketNotificationResponse GetBucketNotification( 116 | GetBucketNotificationArgs args); 117 | GetBucketPolicyResponse GetBucketPolicy(GetBucketPolicyArgs args); 118 | GetBucketReplicationResponse GetBucketReplication( 119 | GetBucketReplicationArgs args); 120 | GetBucketTagsResponse GetBucketTags(GetBucketTagsArgs args); 121 | GetBucketVersioningResponse GetBucketVersioning(GetBucketVersioningArgs args); 122 | GetObjectResponse GetObject(GetObjectArgs args); 123 | GetObjectLockConfigResponse GetObjectLockConfig(GetObjectLockConfigArgs args); 124 | GetObjectRetentionResponse GetObjectRetention(GetObjectRetentionArgs args); 125 | GetObjectTagsResponse GetObjectTags(GetObjectTagsArgs args); 126 | GetPresignedObjectUrlResponse GetPresignedObjectUrl( 127 | GetPresignedObjectUrlArgs args); 128 | GetPresignedPostFormDataResponse GetPresignedPostFormData(PostPolicy policy); 129 | IsObjectLegalHoldEnabledResponse IsObjectLegalHoldEnabled( 130 | IsObjectLegalHoldEnabledArgs args); 131 | ListBucketsResponse ListBuckets(ListBucketsArgs args); 132 | ListBucketsResponse ListBuckets(); 133 | ListenBucketNotificationResponse ListenBucketNotification( 134 | ListenBucketNotificationArgs args); 135 | ListObjectsResponse ListObjectsV1(ListObjectsV1Args args); 136 | ListObjectsResponse ListObjectsV2(ListObjectsV2Args args); 137 | ListObjectsResponse ListObjectVersions(ListObjectVersionsArgs args); 138 | MakeBucketResponse MakeBucket(MakeBucketArgs args); 139 | PutObjectResponse PutObject(PutObjectApiArgs args); 140 | RemoveBucketResponse RemoveBucket(RemoveBucketArgs args); 141 | RemoveObjectResponse RemoveObject(RemoveObjectArgs args); 142 | RemoveObjectsResponse RemoveObjects(RemoveObjectsApiArgs args); 143 | SetBucketEncryptionResponse SetBucketEncryption(SetBucketEncryptionArgs args); 144 | SetBucketLifecycleResponse SetBucketLifecycle(SetBucketLifecycleArgs args); 145 | SetBucketNotificationResponse SetBucketNotification( 146 | SetBucketNotificationArgs args); 147 | SetBucketPolicyResponse SetBucketPolicy(SetBucketPolicyArgs args); 148 | SetBucketReplicationResponse SetBucketReplication( 149 | SetBucketReplicationArgs args); 150 | SetBucketTagsResponse SetBucketTags(SetBucketTagsArgs args); 151 | SetBucketVersioningResponse SetBucketVersioning(SetBucketVersioningArgs args); 152 | SetObjectLockConfigResponse SetObjectLockConfig(SetObjectLockConfigArgs args); 153 | SetObjectRetentionResponse SetObjectRetention(SetObjectRetentionArgs args); 154 | SetObjectTagsResponse SetObjectTags(SetObjectTagsArgs args); 155 | SelectObjectContentResponse SelectObjectContent(SelectObjectContentArgs args); 156 | StatObjectResponse StatObject(StatObjectArgs args); 157 | UploadPartResponse UploadPart(UploadPartArgs args); 158 | UploadPartCopyResponse UploadPartCopy(UploadPartCopyArgs args); 159 | 160 | // Windows API fix: 161 | // 162 | // Windows API headers define `GetObject()` as a macro that expands to either 163 | // `GetObjectA()` or `GetObjectW()`. This means that users can get link errors 164 | // in case that one compilation unit used `GetObject()` macro and other 165 | // didn't. This fixes the issue by providing both functions `GetObject()` can 166 | // expand to as inline wrappers. 167 | #if defined(_WIN32) 168 | inline GetObjectResponse GetObjectA(const GetObjectArgs& args) { 169 | return GetObject(args); 170 | } 171 | 172 | inline GetObjectResponse GetObjectW(const GetObjectArgs& args) { 173 | return GetObject(args); 174 | } 175 | #endif // _WIN32 176 | 177 | }; // class BaseClient 178 | 179 | } // namespace minio::s3 180 | 181 | #if defined(_WIN32) && defined(MINIO_CPP_GET_OBJECT_DEFINED) 182 | #undef MINIO_CPP_GET_OBJECT_DEFINED 183 | #pragma pop_macro("GetObject") 184 | #endif 185 | 186 | #endif // MINIO_CPP_BASECLIENT_H_INCLUDED 187 | -------------------------------------------------------------------------------- /include/miniocpp/client.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_CLIENT_H_INCLUDED 19 | #define MINIO_CPP_CLIENT_H_INCLUDED 20 | 21 | #include 22 | #include 23 | 24 | #include "args.h" 25 | #include "baseclient.h" 26 | #include "error.h" 27 | #include "providers.h" 28 | #include "request.h" 29 | #include "response.h" 30 | 31 | namespace minio::s3 { 32 | 33 | class Client; 34 | 35 | class ListObjectsResult { 36 | private: 37 | Client* client_ = nullptr; 38 | ListObjectsArgs args_; 39 | bool failed_ = false; 40 | ListObjectsResponse resp_; 41 | std::list::iterator itr_; 42 | 43 | void Populate(); 44 | 45 | public: 46 | explicit ListObjectsResult(error::Error err); 47 | ListObjectsResult(Client* const client, const ListObjectsArgs& args); 48 | ListObjectsResult(Client* const client, ListObjectsArgs&& args); 49 | ~ListObjectsResult() = default; 50 | 51 | Item& operator*() const { return *itr_; } 52 | explicit operator bool() const { return itr_ != resp_.contents.end(); } 53 | 54 | ListObjectsResult& operator++() { 55 | itr_++; 56 | if (!failed_ && itr_ == resp_.contents.end() && resp_.is_truncated) { 57 | Populate(); 58 | } 59 | return *this; 60 | } 61 | 62 | ListObjectsResult operator++(int) { 63 | ListObjectsResult curr = *this; 64 | ++(*this); 65 | return curr; 66 | } 67 | }; // class ListObjectsResult 68 | 69 | class RemoveObjectsResult { 70 | private: 71 | Client* client_ = nullptr; 72 | RemoveObjectsArgs args_; 73 | bool done_ = false; 74 | RemoveObjectsResponse resp_; 75 | std::list::iterator itr_; 76 | 77 | void Populate(); 78 | 79 | public: 80 | explicit RemoveObjectsResult(error::Error err); 81 | RemoveObjectsResult(Client* const client, const RemoveObjectsArgs& args); 82 | RemoveObjectsResult(Client* const client, RemoveObjectsArgs&& args); 83 | ~RemoveObjectsResult() = default; 84 | 85 | DeleteError& operator*() const { return *itr_; } 86 | explicit operator bool() const { return itr_ != resp_.errors.end(); } 87 | RemoveObjectsResult& operator++() { 88 | itr_++; 89 | if (!done_ && itr_ == resp_.errors.end()) { 90 | Populate(); 91 | } 92 | return *this; 93 | } 94 | RemoveObjectsResult operator++(int) { 95 | RemoveObjectsResult curr = *this; 96 | ++(*this); 97 | return curr; 98 | } 99 | }; // class RemoveObjectsResult 100 | 101 | /** 102 | * Simple Storage Service (aka S3) client to perform bucket and object 103 | * operations. 104 | */ 105 | class Client : public BaseClient { 106 | protected: 107 | StatObjectResponse CalculatePartCount(size_t& part_count, 108 | std::list sources); 109 | ComposeObjectResponse ComposeObject(ComposeObjectArgs args, 110 | std::string& upload_id); 111 | PutObjectResponse PutObject(PutObjectArgs args, std::string& upload_id, 112 | char* buf); 113 | 114 | public: 115 | explicit Client(BaseUrl& base_url, creds::Provider* const provider = nullptr); 116 | ~Client() = default; 117 | 118 | ComposeObjectResponse ComposeObject(ComposeObjectArgs args); 119 | CopyObjectResponse CopyObject(CopyObjectArgs args); 120 | DownloadObjectResponse DownloadObject(DownloadObjectArgs args); 121 | ListObjectsResult ListObjects(ListObjectsArgs args); 122 | PutObjectResponse PutObject(PutObjectArgs args); 123 | UploadObjectResponse UploadObject(UploadObjectArgs args); 124 | RemoveObjectsResult RemoveObjects(RemoveObjectsArgs args); 125 | }; // class Client 126 | 127 | } // namespace minio::s3 128 | 129 | #endif // MINIO_CPP_CLIENT_H_INCLUDED 130 | -------------------------------------------------------------------------------- /include/miniocpp/config.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_CONFIG_H_INCLUDED 19 | #define MINIO_CPP_CONFIG_H_INCLUDED 20 | 21 | #define MINIO_CPP_STRINGIFY(x) #x 22 | #define MINIO_CPP_TO_STRING(x) MINIO_CPP_STRINGIFY(x) 23 | 24 | #define MINIO_CPP_MAJOR_VERSION 0 25 | #define MINIO_CPP_MINOR_VERSION 3 26 | #define MINIO_CPP_PATCH_VERSION 0 27 | 28 | #define MINIO_CPP_VERSION \ 29 | "" MINIO_CPP_TO_STRING(MINIO_CPP_MAJOR_VERSION) "." MINIO_CPP_TO_STRING( \ 30 | MINIO_CPP_MINOR_VERSION) "." MINIO_CPP_TO_STRING(MINIO_CPP_PATCH_VERSION) 31 | 32 | #if defined(_M_X64) || defined(__x86_64__) 33 | #define MINIO_CPP_ARCH_STRING "x86_64" 34 | #elif defined(_M_IX86) || defined(__X86__) || defined(__i386__) 35 | #define MINIO_CPP_ARCH_STRING "x86" 36 | #elif defined(_M_ARM64) || defined(__arm64__) || defined(__aarch64__) 37 | #define MINIO_CPP_ARCH_STRING "arm64" 38 | #elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || \ 39 | defined(__thumb__) || defined(__thumb2__) 40 | #define MINIO_CPP_ARCH_STRING "arm32" 41 | #elif defined(_MIPS_ARCH_MIPS64) || defined(__mips64) 42 | #define MINIO_CPP_ARCH_STRING "mips64" 43 | #elif defined(_MIPS_ARCH_MIPS32) || defined(_M_MRX000) || defined(__mips__) 44 | #define MINIO_CPP_ARCH_STRING "mips32" 45 | #elif (defined(__riscv) || defined(__riscv__)) && defined(__riscv_xlen) 46 | #define MINIO_CPP_ARCH_STRING "riscv" MINIO_CPP_STRINGIFY(__riscv_xlen) 47 | #elif defined(__loongarch__) 48 | #define MINIO_CPP_ARCH_STRING "loongarch" 49 | #elif defined(__s390__) || defined(__s390x__) 50 | #define MINIO_CPP_ARCH_STRING "s390" 51 | #else 52 | #define MINIO_CPP_ARCH_STRING "unknown-arch" 53 | #endif 54 | 55 | #if defined(_WIN32) || defined(__CYGWIN__) 56 | #define MINIO_CPP_PLATFORM_STRING "windows" 57 | #elif defined(__ANDROID__) 58 | #define MINIO_CPP_PLATFORM_STRING "android" 59 | #elif defined(__linux__) || defined(__linux) 60 | #define MINIO_CPP_PLATFORM_STRING "linux" 61 | #elif defined(__APPLE__) || defined(__MACH__) 62 | #define MINIO_CPP_PLATFORM_STRING "darwin" 63 | #elif defined(__FreeBSD__) 64 | #define MINIO_CPP_PLATFORM_STRING "freebsd" 65 | #elif defined(__NetBSD__) 66 | #define MINIO_CPP_PLATFORM_STRING "netbsd" 67 | #elif defined(__OpenBSD__) 68 | #define MINIO_CPP_PLATFORM_STRING "openbsd" 69 | #else 70 | #define MINIO_CPP_PLATFORM_STRING "unknown-os" 71 | #endif 72 | 73 | #define DEFAULT_USER_AGENT \ 74 | "MinIO (" MINIO_CPP_PLATFORM_STRING "; " MINIO_CPP_ARCH_STRING \ 75 | ") minio-cpp/" MINIO_CPP_VERSION "" 76 | 77 | #endif // MINIO_CPP_CONFIG_H_INCLUDED 78 | -------------------------------------------------------------------------------- /include/miniocpp/credentials.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_CREDENTIALS_H_INCLUDED 19 | #define MINIO_CPP_CREDENTIALS_H_INCLUDED 20 | 21 | #include 22 | #include 23 | 24 | #include "error.h" 25 | #include "utils.h" 26 | 27 | namespace minio::creds { 28 | 29 | bool expired(const utils::UtcTime& expiration); 30 | 31 | /** 32 | * Credentials contains access key and secret key with optional session token 33 | * and expiration. 34 | */ 35 | struct Credentials { 36 | error::Error err; 37 | std::string access_key = {}; 38 | std::string secret_key = {}; 39 | std::string session_token = {}; 40 | utils::UtcTime expiration = {}; 41 | 42 | Credentials() = default; 43 | explicit Credentials(error::Error err) : err(std::move(err)) {} 44 | 45 | explicit Credentials(error::Error err, std::string access_key, 46 | std::string secret_key) 47 | : err(std::move(err)), 48 | access_key(std::move(access_key)), 49 | secret_key(std::move(secret_key)) {} 50 | 51 | explicit Credentials(error::Error err, std::string access_key, 52 | std::string secret_key, std::string session_token) 53 | : err(std::move(err)), 54 | access_key(std::move(access_key)), 55 | secret_key(std::move(secret_key)), 56 | session_token(std::move(session_token)) {} 57 | 58 | explicit Credentials(error::Error err, std::string access_key, 59 | std::string secret_key, std::string session_token, 60 | utils::UtcTime expiration) 61 | : err(std::move(err)), 62 | access_key(std::move(access_key)), 63 | secret_key(std::move(secret_key)), 64 | session_token(std::move(session_token)), 65 | expiration(std::move(expiration)) {} 66 | 67 | ~Credentials() = default; 68 | 69 | bool IsExpired() const { return expired(expiration); } 70 | 71 | explicit operator bool() const { 72 | return !err && !access_key.empty() && !expired(expiration); 73 | } 74 | 75 | static Credentials ParseXML(std::string_view data, const std::string& root); 76 | }; // class Credentials 77 | 78 | } // namespace minio::creds 79 | 80 | #endif // MINIO_CPP_CREDENTIALS_H_INCLUDED 81 | -------------------------------------------------------------------------------- /include/miniocpp/error.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_ERROR_H_INCLUDED 19 | #define MINIO_CPP_ERROR_H_INCLUDED 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | namespace minio::error { 26 | 27 | class Error { 28 | private: 29 | std::string msg_; 30 | 31 | public: 32 | Error() = default; 33 | 34 | explicit Error(std::string msg) : msg_(std::move(msg)) {} 35 | 36 | Error(const Error&) = default; 37 | Error(Error&& v) = default; 38 | 39 | Error& operator=(const Error&) = default; 40 | Error& operator=(Error&& v) = default; 41 | 42 | ~Error() = default; 43 | 44 | const std::string& String() const { return msg_; } 45 | explicit operator bool() const { return !msg_.empty(); } 46 | 47 | friend std::ostream& operator<<(std::ostream& s, const Error& e) { 48 | return s << e.msg_; 49 | } 50 | }; // class Error 51 | 52 | extern const Error SUCCESS; 53 | 54 | template 55 | inline T_RESULT make(TA&&... args) { 56 | return T_RESULT{Error(std::forward(args)...)}; 57 | } 58 | 59 | } // namespace minio::error 60 | 61 | #endif // MINIO_CPP_ERROR_H_INCLUDED 62 | -------------------------------------------------------------------------------- /include/miniocpp/http.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_HTTP_H_INCLUDED 19 | #define MINIO_CPP_HTTP_H_INCLUDED 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "error.h" 30 | #include "utils.h" 31 | 32 | namespace minio::http { 33 | 34 | enum class Method { kGet, kHead, kPost, kPut, kDelete }; 35 | 36 | //! MethodToString converts http Method enum to string. 37 | const char* MethodToString(Method method) noexcept; 38 | 39 | /** 40 | * Url represents HTTP URL and it's components. 41 | */ 42 | struct Url { 43 | bool https = false; 44 | std::string host; 45 | unsigned int port = 0; 46 | std::string path; 47 | std::string query_string; 48 | 49 | Url() = default; 50 | explicit Url(bool https, std::string host, unsigned int port, 51 | std::string path, std::string query_string) 52 | : https(https), 53 | host(std::move(host)), 54 | port(port), 55 | path(std::move(path)), 56 | query_string(std::move(query_string)) {} 57 | ~Url() = default; 58 | 59 | explicit operator bool() const { return !host.empty(); } 60 | 61 | std::string String() const; 62 | std::string HostHeaderValue() const; 63 | static Url Parse(std::string value); 64 | }; // struct Url 65 | 66 | struct DataFunctionArgs; 67 | 68 | using DataFunction = std::function; 69 | 70 | struct ProgressFunctionArgs; 71 | 72 | using ProgressFunction = std::function; 73 | 74 | struct Response; 75 | 76 | struct DataFunctionArgs { 77 | curlpp::Easy* handle = nullptr; 78 | Response* response = nullptr; 79 | std::string datachunk; 80 | void* userdata = nullptr; 81 | 82 | DataFunctionArgs() = default; 83 | DataFunctionArgs(curlpp::Easy* handle, Response* response, void* userdata) 84 | : handle(handle), response(response), userdata(userdata) {} 85 | DataFunctionArgs(curlpp::Easy* handle, Response* response, 86 | std::string datachunk, void* userdata) 87 | : handle(handle), 88 | response(response), 89 | datachunk(std::move(datachunk)), 90 | userdata(userdata) {} 91 | 92 | ~DataFunctionArgs() = default; 93 | }; // struct DataFunctionArgs 94 | 95 | struct ProgressFunctionArgs { 96 | double download_total_bytes = 0.0; 97 | double downloaded_bytes = 0.0; 98 | double upload_total_bytes = 0.0; 99 | double uploaded_bytes = 0.0; 100 | double download_speed = 0.0; 101 | double upload_speed = 0.0; 102 | void* userdata = nullptr; 103 | }; // struct ProgressFunctionArgs 104 | 105 | struct Request { 106 | Method method; 107 | http::Url url; 108 | utils::Multimap headers; 109 | std::string_view body; 110 | DataFunction datafunc = nullptr; 111 | void* userdata = nullptr; 112 | ProgressFunction progressfunc = nullptr; 113 | void* progress_userdata = nullptr; 114 | bool debug = false; 115 | bool ignore_cert_check = false; 116 | std::string ssl_cert_file; 117 | std::string key_file; 118 | std::string cert_file; 119 | 120 | Request(Method method, Url url); 121 | ~Request() = default; 122 | 123 | Response Execute(); 124 | 125 | explicit operator bool() const { 126 | if (method < Method::kGet || method > Method::kDelete) return false; 127 | return static_cast(url); 128 | } 129 | 130 | private: 131 | Response execute(); 132 | }; // struct Request 133 | 134 | struct Response { 135 | std::string error; 136 | DataFunction datafunc = nullptr; 137 | void* userdata = nullptr; 138 | int status_code = 0; 139 | utils::Multimap headers; 140 | std::string body; 141 | 142 | Response() = default; 143 | ~Response() = default; 144 | 145 | size_t ResponseCallback(curlpp::Multi* const requests, 146 | curlpp::Easy* const request, const char* const buffer, 147 | size_t size, size_t length); 148 | 149 | explicit operator bool() const { 150 | return error.empty() && status_code >= 200 && status_code <= 299; 151 | } 152 | 153 | error::Error Error() const; 154 | 155 | private: 156 | std::string response_; 157 | bool continue100_ = false; 158 | bool status_code_read_ = false; 159 | bool headers_read_ = false; 160 | 161 | error::Error ReadStatusCode(); 162 | error::Error ReadHeaders(); 163 | }; // struct Response 164 | 165 | } // namespace minio::http 166 | 167 | #endif // MINIO_CPP_HTTP_H_INCLUDED 168 | -------------------------------------------------------------------------------- /include/miniocpp/providers.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_PROVIDERS_H_INCLUDED 19 | #define MINIO_CPP_PROVIDERS_H_INCLUDED 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "credentials.h" 27 | #include "error.h" 28 | #include "http.h" 29 | 30 | namespace minio::creds { 31 | 32 | // 1 day. 33 | static constexpr unsigned DEFAULT_DURATION_SECONDS = 60 * 60 * 24; 34 | 35 | // 15 minutes. 36 | static constexpr unsigned MIN_DURATION_SECONDS = 60 * 15; 37 | 38 | // 7 days. 39 | static constexpr unsigned MAX_DURATION_SECONDS = 60 * 60 * 24 * 7; 40 | 41 | struct Jwt { 42 | std::string token; 43 | unsigned int expiry = 0; 44 | 45 | Jwt() = default; 46 | explicit Jwt(std::string token, unsigned int expiry) 47 | : token(std::move(token)), expiry(expiry) {} 48 | ~Jwt() = default; 49 | 50 | explicit operator bool() const { return !token.empty(); } 51 | }; // struct Jwt 52 | 53 | using JwtFunction = std::function; 54 | 55 | error::Error checkLoopbackHost(const std::string& host); 56 | 57 | /** 58 | * Credential provider interface. 59 | */ 60 | class Provider { 61 | protected: 62 | error::Error err_; 63 | Credentials creds_; 64 | 65 | public: 66 | Provider() = default; 67 | virtual ~Provider(); 68 | 69 | explicit operator bool() const { return !err_; } 70 | 71 | virtual Credentials Fetch() = 0; 72 | }; // class Provider 73 | 74 | class ChainedProvider : public Provider { 75 | private: 76 | std::list providers_; 77 | Provider* provider_ = nullptr; 78 | 79 | public: 80 | explicit ChainedProvider(std::list providers) 81 | : providers_(std::move(providers)) {} 82 | 83 | virtual ~ChainedProvider(); 84 | 85 | virtual Credentials Fetch() override; 86 | }; // class ChainedProvider 87 | 88 | /** 89 | * Static credential provider. 90 | */ 91 | class StaticProvider : public Provider { 92 | public: 93 | StaticProvider(std::string access_key, std::string secret_key, 94 | std::string session_token = {}); 95 | virtual ~StaticProvider(); 96 | 97 | virtual Credentials Fetch() override; 98 | }; // class StaticProvider 99 | 100 | class EnvAwsProvider : public Provider { 101 | public: 102 | EnvAwsProvider(); 103 | virtual ~EnvAwsProvider(); 104 | 105 | virtual Credentials Fetch() override; 106 | }; // class EnvAwsProvider 107 | 108 | class EnvMinioProvider : public Provider { 109 | public: 110 | EnvMinioProvider(); 111 | virtual ~EnvMinioProvider(); 112 | 113 | virtual Credentials Fetch() override; 114 | }; // class EnvMinioProvider 115 | 116 | class AwsConfigProvider : public Provider { 117 | public: 118 | explicit AwsConfigProvider(std::string filename = {}, 119 | std::string profile = {}); 120 | virtual ~AwsConfigProvider(); 121 | 122 | virtual Credentials Fetch() override; 123 | }; // class AwsConfigProvider 124 | 125 | class MinioClientConfigProvider : public Provider { 126 | public: 127 | explicit MinioClientConfigProvider(std::string filename = {}, 128 | std::string alias = {}); 129 | virtual ~MinioClientConfigProvider(); 130 | 131 | virtual Credentials Fetch() override; 132 | }; // class MinioClientConfigProvider 133 | 134 | class AssumeRoleProvider : public Provider { 135 | private: 136 | http::Url sts_endpoint_; 137 | std::string access_key_; 138 | std::string secret_key_; 139 | std::string region_; 140 | std::string body_; 141 | std::string content_sha256_; 142 | 143 | public: 144 | AssumeRoleProvider(http::Url sts_endpoint, std::string access_key, 145 | std::string secret_key, unsigned int duration_seconds = 0, 146 | std::string policy = {}, std::string region = {}, 147 | std::string role_arn = {}, 148 | std::string role_session_name = {}, 149 | std::string external_id = {}); 150 | 151 | virtual ~AssumeRoleProvider(); 152 | 153 | virtual Credentials Fetch() override; 154 | }; // class AssumeRoleProvider 155 | 156 | class WebIdentityClientGrantsProvider : public Provider { 157 | private: 158 | JwtFunction jwtfunc_ = nullptr; 159 | http::Url sts_endpoint_; 160 | unsigned int duration_seconds_ = 0; 161 | std::string policy_; 162 | std::string role_arn_; 163 | std::string role_session_name_; 164 | 165 | public: 166 | WebIdentityClientGrantsProvider(JwtFunction jwtfunc, http::Url sts_endpoint, 167 | unsigned int duration_seconds = 0, 168 | std::string policy = {}, 169 | std::string role_arn = {}, 170 | std::string role_session_name = {}); 171 | 172 | virtual ~WebIdentityClientGrantsProvider(); 173 | 174 | virtual bool IsWebIdentity() const = 0; 175 | 176 | unsigned int getDurationSeconds(unsigned int expiry) const; 177 | 178 | virtual Credentials Fetch() override; 179 | }; // class WebIdentityClientGrantsProvider 180 | 181 | class ClientGrantsProvider : public WebIdentityClientGrantsProvider { 182 | public: 183 | ClientGrantsProvider(JwtFunction jwtfunc, http::Url sts_endpoint, 184 | unsigned int duration_seconds = 0, 185 | std::string policy = {}, std::string role_arn = {}, 186 | std::string role_session_name = {}); 187 | 188 | virtual ~ClientGrantsProvider(); 189 | 190 | virtual bool IsWebIdentity() const override; 191 | }; // class ClientGrantsProvider 192 | 193 | class WebIdentityProvider : public WebIdentityClientGrantsProvider { 194 | public: 195 | WebIdentityProvider(JwtFunction jwtfunc, http::Url sts_endpoint, 196 | unsigned int duration_seconds = 0, 197 | std::string policy = {}, std::string role_arn = {}, 198 | std::string role_session_name = {}); 199 | 200 | virtual ~WebIdentityProvider(); 201 | 202 | virtual bool IsWebIdentity() const override; 203 | }; // class WebIdentityProvider 204 | 205 | class IamAwsProvider : public Provider { 206 | private: 207 | http::Url custom_endpoint_; 208 | std::string token_file_; 209 | std::string aws_region_; 210 | std::string role_arn_; 211 | std::string role_session_name_; 212 | std::string relative_uri_; 213 | std::string full_uri_; 214 | 215 | public: 216 | explicit IamAwsProvider(http::Url custom_endpoint = http::Url()); 217 | virtual ~IamAwsProvider(); 218 | 219 | virtual Credentials Fetch() override; 220 | 221 | private: 222 | Credentials fetch(http::Url url); 223 | error::Error getRoleName(std::string& role_name, http::Url url) const; 224 | }; // class IamAwsProvider 225 | 226 | class LdapIdentityProvider : public Provider { 227 | private: 228 | http::Url sts_endpoint_; 229 | 230 | public: 231 | LdapIdentityProvider(http::Url sts_endpoint, std::string ldap_username, 232 | std::string ldap_password); 233 | 234 | virtual ~LdapIdentityProvider(); 235 | 236 | virtual Credentials Fetch() override; 237 | }; // class LdapIdentityProvider 238 | 239 | struct CertificateIdentityProvider : public Provider { 240 | private: 241 | http::Url sts_endpoint_; 242 | std::string key_file_; 243 | std::string cert_file_; 244 | std::string ssl_cert_file_; 245 | 246 | public: 247 | CertificateIdentityProvider(http::Url sts_endpoint, std::string key_file, 248 | std::string cert_file, 249 | std::string ssl_cert_file = {}, 250 | unsigned int duration_seconds = 0); 251 | 252 | virtual ~CertificateIdentityProvider(); 253 | 254 | virtual Credentials Fetch() override; 255 | }; // struct CertificateIdentityProvider 256 | 257 | } // namespace minio::creds 258 | 259 | #endif // MINIO_CPP_PROVIDERS_H_INCLUDED 260 | -------------------------------------------------------------------------------- /include/miniocpp/request.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_REQUEST_H_INCLUDED 19 | #define MINIO_CPP_REQUEST_H_INCLUDED 20 | 21 | #include 22 | 23 | #include "error.h" 24 | #include "http.h" 25 | #include "providers.h" 26 | #include "utils.h" 27 | 28 | namespace minio::s3 { 29 | 30 | error::Error getAwsInfo(const std::string& host, bool https, 31 | std::string& region, std::string& aws_s3_prefix, 32 | std::string& aws_domain_suffix, bool& dualstack); 33 | 34 | std::string extractRegion(const std::string& host); 35 | 36 | struct BaseUrl { 37 | bool https = true; 38 | std::string host; 39 | unsigned int port = 0; 40 | std::string region; 41 | std::string aws_s3_prefix; 42 | std::string aws_domain_suffix; 43 | bool dualstack = false; 44 | bool virtual_style = false; 45 | 46 | BaseUrl() = default; 47 | explicit BaseUrl(std::string host, bool https = true, 48 | std::string region = {}); 49 | ~BaseUrl() = default; 50 | 51 | error::Error BuildUrl(http::Url& url, http::Method method, 52 | const std::string& region, 53 | const utils::Multimap& query_params, 54 | const std::string& bucket_name, 55 | const std::string& object_name); 56 | 57 | explicit operator bool() const { return !err_ && !host.empty(); } 58 | 59 | error::Error Error() const { 60 | if (host.empty() && !err_) { 61 | return error::Error("empty host"); 62 | } 63 | return err_; 64 | } 65 | 66 | private: 67 | error::Error err_; 68 | 69 | error::Error BuildAwsUrl(http::Url& url, const std::string& bucket_name, 70 | bool enforce_path_style, const std::string& region); 71 | void BuildListBucketsUrl(http::Url& url, const std::string& region); 72 | }; // struct Url 73 | 74 | struct Request { 75 | http::Method method; 76 | std::string region; 77 | BaseUrl& base_url; 78 | 79 | std::string user_agent; 80 | 81 | utils::Multimap headers; 82 | utils::Multimap query_params; 83 | 84 | std::string bucket_name; 85 | std::string object_name; 86 | 87 | std::string_view body; 88 | 89 | http::DataFunction datafunc = nullptr; 90 | void* userdata = nullptr; 91 | 92 | http::ProgressFunction progressfunc = nullptr; 93 | void* progress_userdata = nullptr; 94 | 95 | std::string sha256; 96 | utils::UtcTime date; 97 | 98 | bool debug = false; 99 | bool ignore_cert_check = false; 100 | std::string ssl_cert_file; 101 | 102 | Request(http::Method method, std::string region, BaseUrl& baseurl, 103 | utils::Multimap extra_headers, utils::Multimap extra_query_params); 104 | 105 | ~Request() = default; 106 | 107 | http::Request ToHttpRequest(creds::Provider* const provider = nullptr); 108 | 109 | private: 110 | void BuildHeaders(http::Url& url, creds::Provider* const provider); 111 | }; // struct Request 112 | 113 | } // namespace minio::s3 114 | 115 | #endif // MINIO_CPP_REQUEST_H_INCLUDED 116 | -------------------------------------------------------------------------------- /include/miniocpp/select.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_SELECT_H_INCLUDED 19 | #define MINIO_CPP_SELECT_H_INCLUDED 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "error.h" 26 | #include "http.h" 27 | #include "types.h" 28 | 29 | namespace minio::s3 { 30 | 31 | class SelectHandler { 32 | private: 33 | SelectResultFunction result_func_ = nullptr; 34 | 35 | bool done_ = false; 36 | std::string response_; 37 | 38 | std::string prelude_; 39 | bool prelude_read_ = false; 40 | 41 | std::string prelude_crc_; 42 | bool prelude_crc_read_ = false; 43 | 44 | size_t total_length_ = 0; 45 | 46 | std::string data_; 47 | bool data_read_ = false; 48 | 49 | std::string message_crc_; 50 | bool message_crc_read_ = false; 51 | 52 | void Reset(); 53 | bool ReadPrelude(); 54 | bool ReadPreludeCrc(); 55 | bool ReadData(); 56 | bool ReadMessageCrc(); 57 | error::Error DecodeHeader(std::map& headers, 58 | std::string data); 59 | bool process(const http::DataFunctionArgs& args, bool& cont); 60 | 61 | public: 62 | explicit SelectHandler(SelectResultFunction result_func) 63 | : result_func_(std::move(result_func)) {} 64 | 65 | ~SelectHandler() = default; 66 | 67 | bool DataFunction(const http::DataFunctionArgs& args); 68 | }; // struct SelectHandler 69 | 70 | } // namespace minio::s3 71 | 72 | #endif // MINIO_CPP_SELECT_H_INCLUDED 73 | -------------------------------------------------------------------------------- /include/miniocpp/signer.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_SIGNER_H_INCLUDED 19 | #define MINIO_CPP_SIGNER_H_INCLUDED 20 | 21 | #include 22 | 23 | #include "http.h" 24 | #include "utils.h" 25 | 26 | namespace minio::signer { 27 | 28 | std::string GetScope(const utils::UtcTime& time, const std::string& region, 29 | const std::string& service_name); 30 | std::string GetCanonicalRequestHash(const std::string& method, 31 | const std::string& uri, 32 | const std::string& query_string, 33 | const std::string& headers, 34 | const std::string& signed_headers, 35 | const std::string& content_sha256); 36 | std::string GetStringToSign(const utils::UtcTime& date, 37 | const std::string& scope, 38 | const std::string& canonical_request_hash); 39 | std::string HmacHash(std::string_view key, std::string_view data); 40 | std::string GetSigningKey(const std::string& secret_key, 41 | const utils::UtcTime& date, std::string_view region, 42 | std::string_view service_name); 43 | std::string GetSignature(std::string_view signing_key, 44 | std::string_view string_to_sign); 45 | std::string GetAuthorization(const std::string& access_key, 46 | const std::string& scope, 47 | const std::string& signed_headers, 48 | const std::string& signature); 49 | utils::Multimap SignV4(const std::string& service_name, http::Method method, 50 | const std::string& uri, const std::string& region, 51 | utils::Multimap& headers, utils::Multimap query_params, 52 | const std::string& access_key, 53 | const std::string& secret_key, 54 | const std::string& content_sha256, 55 | const utils::UtcTime& date); 56 | utils::Multimap SignV4S3(http::Method method, const std::string& uri, 57 | const std::string& region, utils::Multimap& headers, 58 | utils::Multimap query_params, 59 | const std::string& access_key, 60 | const std::string& secret_key, 61 | const std::string& content_sha256, 62 | const utils::UtcTime& date); 63 | utils::Multimap SignV4STS(http::Method method, const std::string& uri, 64 | const std::string& region, utils::Multimap& headers, 65 | utils::Multimap query_params, 66 | const std::string& access_key, 67 | const std::string& secret_key, 68 | const std::string& content_sha256, 69 | const utils::UtcTime& date); 70 | utils::Multimap PresignV4(http::Method method, const std::string& host, 71 | const std::string& uri, const std::string& region, 72 | utils::Multimap& query_params, 73 | const std::string& access_key, 74 | const std::string& secret_key, 75 | const utils::UtcTime& date, unsigned int expires); 76 | std::string PostPresignV4(const std::string& data, 77 | const std::string& secret_key, 78 | const utils::UtcTime& date, 79 | const std::string& region); 80 | 81 | } // namespace minio::signer 82 | 83 | #endif // MINIO_CPP_SIGNER_H_INCLUDED 84 | -------------------------------------------------------------------------------- /include/miniocpp/sse.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_SSE_H_INCLUDED 19 | #define MINIO_CPP_SSE_H_INCLUDED 20 | 21 | #include 22 | 23 | #include "utils.h" 24 | 25 | namespace minio::s3 { 26 | 27 | class Sse { 28 | protected: 29 | utils::Multimap headers_; 30 | utils::Multimap copy_headers_; 31 | 32 | public: 33 | Sse(); 34 | virtual ~Sse(); 35 | 36 | utils::Multimap Headers() const; 37 | utils::Multimap CopyHeaders() const; 38 | 39 | virtual bool TlsRequired() const = 0; 40 | }; // class Sse 41 | 42 | class SseCustomerKey : public Sse { 43 | public: 44 | explicit SseCustomerKey(std::string_view key); 45 | virtual ~SseCustomerKey(); 46 | 47 | virtual bool TlsRequired() const override; 48 | }; // class SseCustomerKey 49 | 50 | class SseKms : public Sse { 51 | public: 52 | SseKms(std::string_view key, std::string_view context); 53 | virtual ~SseKms(); 54 | 55 | virtual bool TlsRequired() const override; 56 | }; // class SseKms 57 | 58 | class SseS3 : public Sse { 59 | public: 60 | SseS3(); 61 | virtual ~SseS3(); 62 | 63 | virtual bool TlsRequired() const override; 64 | }; // class SseS3 65 | 66 | } // namespace minio::s3 67 | 68 | #endif // MINIO_CPP_SSE_H_INCLUDED 69 | -------------------------------------------------------------------------------- /include/miniocpp/utils.h: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #ifndef MINIO_CPP_UTILS_H_INCLUDED 19 | #define MINIO_CPP_UTILS_H_INCLUDED 20 | 21 | #include 22 | 23 | #ifndef _WIN32 24 | #include 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "error.h" 37 | 38 | namespace minio::utils { 39 | 40 | inline constexpr unsigned int kMaxMultipartCount = 10000; // 10000 parts 41 | inline constexpr uint64_t kMaxObjectSize = 5'497'558'138'880; // 5TiB 42 | inline constexpr uint64_t kMaxPartSize = 5'368'709'120; // 5GiB 43 | inline constexpr unsigned int kMinPartSize = 5 * 1024 * 1024; // 5MiB 44 | 45 | // GetEnv copies the environment variable name into var 46 | bool GetEnv(std::string& var, const char* name); 47 | 48 | std::string GetHomeDir(); 49 | 50 | std::string Printable(const std::string& s); 51 | 52 | unsigned long CRC32(std::string_view str); 53 | 54 | unsigned int Int(std::string_view str); 55 | 56 | // FormatTime formats time as per format. 57 | std::string FormatTime(const std::tm& time, const char* format); 58 | 59 | // StringToBool converts string to bool. 60 | bool StringToBool(const std::string& str); 61 | 62 | // BoolToString converts bool to string. 63 | inline const char* BoolToString(bool b) { return b ? "true" : "false"; } 64 | 65 | // Trim trims leading and trailing character of a string. 66 | std::string Trim(std::string_view str, char ch = ' '); 67 | 68 | // CheckNonEmptyString checks whether string is not empty after trimming 69 | // whitespaces. 70 | bool CheckNonEmptyString(std::string_view str); 71 | 72 | // ToLower converts string to lower case. 73 | std::string ToLower(const std::string& str); 74 | 75 | // StartsWith returns whether str starts with prefix or not. 76 | bool StartsWith(std::string_view str, std::string_view prefix); 77 | 78 | // EndsWith returns whether str ends with suffix or not. 79 | bool EndsWith(std::string_view str, std::string_view suffix); 80 | 81 | // Contains returns whether str has ch. 82 | bool Contains(std::string_view str, char ch); 83 | 84 | // Contains returns whether str has substr. 85 | bool Contains(std::string_view str, std::string_view substr); 86 | 87 | // Join returns a string of joined values by delimiter. 88 | std::string Join(const std::list& values, 89 | const std::string& delimiter); 90 | 91 | // Join returns a string of joined values by delimiter. 92 | std::string Join(const std::vector& values, 93 | const std::string& delimiter); 94 | 95 | // EncodePath does URL encoding of path. It also normalizes multiple slashes. 96 | std::string EncodePath(const std::string& path); 97 | 98 | // Sha256hash computes SHA-256 of data and return hash as hex encoded value. 99 | std::string Sha256Hash(std::string_view str); 100 | 101 | // Base64Encode encodes string to base64. 102 | std::string Base64Encode(std::string_view str); 103 | 104 | // Md5sumHash computes MD5 of data and return hash as Base64 encoded value. 105 | std::string Md5sumHash(std::string_view str); 106 | 107 | error::Error CheckBucketName(std::string_view bucket_name, bool strict = false); 108 | error::Error ReadPart(std::istream& stream, char* buf, size_t size, 109 | size_t& bytes_read); 110 | error::Error CalcPartInfo(long object_size, size_t& part_size, 111 | long& part_count); 112 | 113 | /** 114 | * UtcTime represents date and time in UTC timezone. 115 | */ 116 | class UtcTime { 117 | private: 118 | std::time_t secs_ = {}; 119 | long usecs_ = 0L; 120 | 121 | static std::tm auxLocaltime(const std::time_t& time); 122 | std::tm getBrokenDownTime() const { return auxLocaltime(secs_); } 123 | static std::time_t toUtcSeconds(const std::time_t time); 124 | 125 | public: 126 | UtcTime() = default; 127 | 128 | UtcTime(std::time_t secs) : secs_(secs) {} 129 | UtcTime(std::time_t secs, long usecs) : secs_(secs), usecs_(usecs) {} 130 | 131 | ~UtcTime() = default; 132 | 133 | void Add(std::time_t seconds) { secs_ += seconds; } 134 | 135 | void ToLocalTime(std::tm& time); 136 | 137 | std::string ToSignerDate() const; 138 | 139 | std::string ToAmzDate() const; 140 | 141 | std::string ToHttpHeaderValue() const; 142 | 143 | static UtcTime FromHttpHeaderValue(const char* value); 144 | 145 | std::string ToISO8601UTC() const; 146 | 147 | static UtcTime FromISO8601UTC(const char* value); 148 | 149 | static UtcTime Now(); 150 | 151 | explicit operator bool() const { return secs_ != 0 && usecs_ != 0; } 152 | 153 | int Compare(const UtcTime& rhs) const; 154 | 155 | bool Equal(const UtcTime& rhs) const { return Compare(rhs) == 0; } 156 | 157 | bool operator==(const UtcTime& rhs) const { return Equal(rhs); } 158 | 159 | bool operator!=(const UtcTime& rhs) const { return !operator==(rhs); } 160 | 161 | bool operator<(const UtcTime& rhs) const { return Compare(rhs) < 0; } 162 | 163 | bool operator>(const UtcTime& rhs) const { return Compare(rhs) > 0; } 164 | 165 | bool operator<=(const UtcTime& rhs) const { return !operator>(rhs); } 166 | 167 | bool operator>=(const UtcTime& rhs) const { return !operator<(rhs); } 168 | 169 | #if __cplusplus >= 202002L 170 | auto operator<=>(const UtcTime& rhs) const { return Compare(rhs); } 171 | #endif 172 | 173 | friend std::ostream& operator<<(std::ostream& s, const UtcTime& v) { 174 | return s << v.ToISO8601UTC(); 175 | } 176 | }; // class UtcTime 177 | 178 | /** 179 | * Multimap represents dictionary of keys and their multiple values. 180 | */ 181 | class Multimap { 182 | private: 183 | std::map> map_; 184 | std::map> keys_; 185 | 186 | public: 187 | Multimap() = default; 188 | Multimap(const Multimap& headers) = default; 189 | Multimap& operator=(const Multimap& headers) = default; 190 | Multimap(Multimap&& headers) = default; 191 | Multimap& operator=(Multimap&& headers) = default; 192 | ~Multimap() = default; 193 | 194 | void Add(std::string key, std::string value); 195 | 196 | void AddAll(const Multimap& headers); 197 | 198 | std::list ToHttpHeaders() const; 199 | 200 | std::string ToQueryString() const; 201 | 202 | explicit operator bool() const { return !map_.empty(); } 203 | 204 | bool Contains(std::string_view key) const; 205 | 206 | std::list Get(std::string_view key) const; 207 | 208 | std::string GetFront(std::string_view key) const; 209 | 210 | std::list Keys() const; 211 | 212 | void GetCanonicalHeaders(std::string& signed_headers, 213 | std::string& canonical_headers) const; 214 | 215 | std::string GetCanonicalQueryString() const; 216 | }; // class Multimap 217 | 218 | /** 219 | * CharBuffer represents stream buffer wrapping character array and its size. 220 | */ 221 | struct CharBuffer : std::streambuf { 222 | CharBuffer(char* buf, size_t size) { this->setg(buf, buf, buf + size); } 223 | virtual ~CharBuffer(); 224 | 225 | virtual pos_type seekpos(pos_type sp, std::ios_base::openmode which) override; 226 | 227 | virtual pos_type seekoff( 228 | off_type off, std::ios_base::seekdir dir, 229 | std::ios_base::openmode which = std::ios_base::in) override; 230 | }; // struct CharBuffer 231 | 232 | } // namespace minio::utils 233 | 234 | #endif // MINIO_CPP_UTILS_H_INCLUDED 235 | -------------------------------------------------------------------------------- /miniocpp-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | find_package(OpenSSL REQUIRED) 4 | find_package(unofficial-curlpp CONFIG REQUIRED) 5 | find_package(unofficial-inih CONFIG REQUIRED) 6 | find_package(nlohmann_json CONFIG REQUIRED) 7 | find_package(pugixml CONFIG REQUIRED) 8 | find_package(ZLIB REQUIRED) 9 | 10 | include("${CMAKE_CURRENT_LIST_DIR}/miniocpp-targets.cmake") 11 | -------------------------------------------------------------------------------- /miniocpp.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 5 | 6 | Name: @PROJECT_NAME@ 7 | Description: @PROJECT_DESCRIPTION@ 8 | Version: @PROJECT_VERSION@ 9 | 10 | Requires: 11 | Libs: -L${libdir} -lminiocpp 12 | Cflags: -I${includedir} -------------------------------------------------------------------------------- /src/credentials.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include "miniocpp/credentials.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "miniocpp/error.h" 25 | #include "miniocpp/utils.h" 26 | 27 | namespace minio::creds { 28 | 29 | bool expired(const utils::UtcTime& expiration) { 30 | if (!expiration) return false; 31 | utils::UtcTime now = utils::UtcTime::Now(); 32 | now.Add(10); 33 | return expiration < now; 34 | } 35 | 36 | Credentials Credentials::ParseXML(std::string_view data, 37 | const std::string& root) { 38 | pugi::xml_document xdoc; 39 | pugi::xml_parse_result result = xdoc.load_string(data.data()); 40 | if (!result) { 41 | return error::make("unable to parse XML"); 42 | } 43 | auto credentials = xdoc.select_node((root + "/Credentials").c_str()); 44 | 45 | auto text = credentials.node().select_node("AccessKeyId/text()"); 46 | std::string access_key = text.node().value(); 47 | 48 | text = credentials.node().select_node("SecretAccessKey/text()"); 49 | std::string secret_key = text.node().value(); 50 | 51 | text = credentials.node().select_node("SessionToken/text()"); 52 | std::string session_token = text.node().value(); 53 | 54 | text = credentials.node().select_node("Expiration/text()"); 55 | auto expiration = utils::UtcTime::FromISO8601UTC(text.node().value()); 56 | 57 | return Credentials(error::SUCCESS, std::move(access_key), 58 | std::move(secret_key), std::move(session_token), 59 | expiration); 60 | } 61 | 62 | } // namespace minio::creds 63 | -------------------------------------------------------------------------------- /src/error.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include "miniocpp/error.h" 19 | 20 | namespace minio::error { 21 | 22 | const Error SUCCESS; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/select.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include "miniocpp/select.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "miniocpp/error.h" 25 | #include "miniocpp/http.h" 26 | #include "miniocpp/types.h" 27 | #include "miniocpp/utils.h" 28 | 29 | namespace minio::s3 { 30 | 31 | void SelectHandler::Reset() { 32 | prelude_.clear(); 33 | prelude_read_ = false; 34 | 35 | prelude_crc_.clear(); 36 | prelude_crc_read_ = false; 37 | 38 | data_.clear(); 39 | data_read_ = false; 40 | 41 | message_crc_.clear(); 42 | message_crc_read_ = false; 43 | } 44 | 45 | bool SelectHandler::ReadPrelude() { 46 | if (response_.length() < 8) return false; 47 | 48 | prelude_read_ = true; 49 | prelude_ = response_.substr(0, 8); 50 | response_.erase(0, 8); 51 | 52 | return true; 53 | } 54 | 55 | bool SelectHandler::ReadPreludeCrc() { 56 | if (response_.length() < 4) return false; 57 | 58 | prelude_crc_read_ = true; 59 | prelude_crc_ = response_.substr(0, 4); 60 | response_.erase(0, 4); 61 | 62 | return true; 63 | } 64 | 65 | bool SelectHandler::ReadData() { 66 | size_t data_length = total_length_ - 8 - 4 - 4; 67 | if (response_.length() < data_length) return false; 68 | 69 | data_read_ = true; 70 | data_ = response_.substr(0, data_length); 71 | response_.erase(0, data_length); 72 | 73 | return true; 74 | } 75 | 76 | bool SelectHandler::ReadMessageCrc() { 77 | if (response_.length() < 4) return false; 78 | 79 | message_crc_read_ = true; 80 | message_crc_ = response_.substr(0, 4); 81 | response_.erase(0, 4); 82 | 83 | return true; 84 | } 85 | 86 | error::Error SelectHandler::DecodeHeader( 87 | std::map& headers, std::string data) { 88 | while (true) { 89 | size_t length = static_cast(data[0]); 90 | data.erase(0, 1); 91 | if (!length) break; 92 | 93 | std::string name = data.substr(0, length); 94 | data.erase(0, length); 95 | 96 | if (data[0] != 7) { 97 | return error::Error("header value type is not 7"); 98 | } 99 | data.erase(0, 1); 100 | 101 | length = (static_cast(static_cast(data[0])) << 8) | 102 | static_cast(data[1]); 103 | data.erase(0, 2); 104 | 105 | std::string value = data.substr(0, length); 106 | data.erase(0, length); 107 | 108 | headers[name] = value; 109 | } 110 | 111 | return error::SUCCESS; 112 | } 113 | 114 | bool SelectHandler::process(const http::DataFunctionArgs& /* args */, 115 | bool& cont) { 116 | if (!prelude_read_ && !ReadPrelude()) return true; 117 | 118 | if (!prelude_crc_read_) { 119 | if (!ReadPreludeCrc()) return true; 120 | 121 | unsigned long got = utils::CRC32(prelude_); 122 | unsigned long expected = utils::Int(prelude_crc_); 123 | if (got != expected) { 124 | done_ = true; 125 | std::string msg("prelude CRC mismatch; expected: "); 126 | msg += std::to_string(expected) + ", got: " + std::to_string(got); 127 | result_func_(error::make(msg)); 128 | return false; 129 | } 130 | total_length_ = utils::Int(prelude_.substr(0, 4)); 131 | } 132 | 133 | if (!data_read_ && !ReadData()) return true; 134 | 135 | if (!message_crc_read_) { 136 | if (!ReadMessageCrc()) return true; 137 | 138 | std::string message = prelude_ + prelude_crc_ + data_; 139 | unsigned long got = utils::CRC32(message); 140 | unsigned long expected = utils::Int(message_crc_); 141 | if (got != expected) { 142 | done_ = true; 143 | std::string msg("message CRC mismatch; expected: "); 144 | msg += std::to_string(expected) + ", got: " + std::to_string(got); 145 | result_func_(error::make(msg)); 146 | return false; 147 | } 148 | } 149 | 150 | size_t header_length = utils::Int(prelude_.substr(4)); 151 | std::string headerdata = data_.substr(0, header_length); 152 | data_.erase(0, header_length); 153 | std::map headers; 154 | if (error::Error err = DecodeHeader(headers, headerdata)) { 155 | done_ = true; 156 | result_func_(SelectResult(err)); 157 | return false; 158 | } 159 | 160 | if (headers[":message-type"] == "error") { 161 | done_ = true; 162 | result_func_(error::make(headers[":error-code"] + ": " + 163 | headers[":error-message"])); 164 | return false; 165 | } 166 | 167 | if (headers[":event-type"] == "End") { 168 | done_ = true; 169 | result_func_(SelectResult()); 170 | return false; 171 | } 172 | 173 | if (headers[":event-type"] == "Cont" || total_length_ <= header_length || 174 | total_length_ - header_length <= 16) { 175 | Reset(); 176 | return true; 177 | } 178 | 179 | size_t payload_length = (total_length_ - header_length) - 16; 180 | std::string payload = data_.substr(0, payload_length); 181 | 182 | if (headers[":event-type"] == "Progress" || 183 | headers[":event-type"] == "Stats") { 184 | pugi::xml_document xdoc; 185 | pugi::xml_parse_result result = xdoc.load_string(payload.data()); 186 | if (!result) { 187 | done_ = true; 188 | result_func_( 189 | error::make("unable to parse XML; " + payload)); 190 | return false; 191 | } 192 | 193 | std::string xpath; 194 | xpath = "/" + headers[":event-type"]; 195 | auto root = xdoc.select_node(xpath.c_str()); 196 | pugi::xpath_node text; 197 | std::string value; 198 | long int bytes_scanned = -1; 199 | long int bytes_processed = -1; 200 | long int bytes_returned = -1; 201 | 202 | text = root.node().select_node("BytesScanned/text()"); 203 | value = text.node().value(); 204 | if (!value.empty()) bytes_scanned = std::stol(value); 205 | 206 | text = root.node().select_node("BytesProcessed/text()"); 207 | value = text.node().value(); 208 | if (!value.empty()) bytes_processed = std::stol(value); 209 | 210 | text = root.node().select_node("BytesReturned/text()"); 211 | value = text.node().value(); 212 | if (!value.empty()) bytes_returned = std::stol(value); 213 | 214 | cont = result_func_( 215 | SelectResult(bytes_scanned, bytes_processed, bytes_returned)); 216 | Reset(); 217 | done_ = !cont; 218 | return cont; 219 | } 220 | 221 | if (headers[":event-type"] == "Records") { 222 | cont = result_func_(SelectResult(payload)); 223 | Reset(); 224 | done_ = !cont; 225 | return cont; 226 | } 227 | 228 | done_ = true; 229 | result_func_(error::make(std::string("unknown event-type ") + 230 | headers[":event-type"])); 231 | return false; 232 | } 233 | 234 | bool SelectHandler::DataFunction(const http::DataFunctionArgs& args) { 235 | if (done_) return false; 236 | 237 | response_ += args.datachunk; 238 | 239 | while (true) { 240 | bool cont = false; 241 | if (!process(args, cont)) return false; 242 | if (!cont) return true; 243 | } 244 | } 245 | 246 | } // namespace minio::s3 247 | -------------------------------------------------------------------------------- /src/signer.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include "miniocpp/signer.h" 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "miniocpp/http.h" 29 | #include "miniocpp/utils.h" 30 | 31 | namespace minio::signer { 32 | 33 | std::string GetScope(const utils::UtcTime& time, const std::string& region, 34 | const std::string& service_name) { 35 | return time.ToSignerDate() + "/" + region + "/" + service_name + 36 | "/aws4_request"; 37 | } 38 | 39 | std::string GetCanonicalRequestHash(const std::string& method, 40 | const std::string& uri, 41 | const std::string& query_string, 42 | const std::string& headers, 43 | const std::string& signed_headers, 44 | const std::string& content_sha256) { 45 | // CanonicalRequest = 46 | // HTTPRequestMethod + '\n' + 47 | // CanonicalURI + '\n' + 48 | // CanonicalQueryString + '\n' + 49 | // CanonicalHeaders + '\n\n' + 50 | // SignedHeaders + '\n' + 51 | // HexEncode(Hash(RequestPayload)) 52 | std::string canonical_request = method + "\n" + uri + "\n" + query_string + 53 | "\n" + headers + "\n\n" + signed_headers + 54 | "\n" + content_sha256; 55 | return utils::Sha256Hash(canonical_request); 56 | } 57 | 58 | std::string GetStringToSign(const utils::UtcTime& date, 59 | const std::string& scope, 60 | const std::string& canonical_request_hash) { 61 | return "AWS4-HMAC-SHA256\n" + date.ToAmzDate() + "\n" + scope + "\n" + 62 | canonical_request_hash; 63 | } 64 | 65 | std::string HmacHash(std::string_view key, std::string_view data) { 66 | std::array hash; 67 | unsigned int hash_len; 68 | 69 | HMAC(EVP_sha256(), key.data(), static_cast(key.size()), 70 | reinterpret_cast(data.data()), 71 | static_cast(data.size()), hash.data(), &hash_len); 72 | 73 | return std::string{reinterpret_cast(hash.data()), hash_len}; 74 | } 75 | 76 | std::string GetSigningKey(const std::string& secret_key, 77 | const utils::UtcTime& date, std::string_view region, 78 | std::string_view service_name) { 79 | std::string date_key = HmacHash("AWS4" + secret_key, date.ToSignerDate()); 80 | std::string date_region_key = HmacHash(date_key, region); 81 | std::string date_region_service_key = HmacHash(date_region_key, service_name); 82 | return HmacHash(date_region_service_key, "aws4_request"); 83 | } 84 | 85 | std::string GetSignature(std::string_view signing_key, 86 | std::string_view string_to_sign) { 87 | std::string hash = HmacHash(signing_key, string_to_sign); 88 | std::string signature; 89 | char buf[3]; 90 | for (std::size_t i = 0, n_size = hash.size(); i < n_size; ++i) { 91 | snprintf(buf, 3, "%02x", (unsigned char)hash[i]); 92 | signature += buf; 93 | } 94 | return signature; 95 | } 96 | 97 | std::string GetAuthorization(const std::string& access_key, 98 | const std::string& scope, 99 | const std::string& signed_headers, 100 | const std::string& signature) { 101 | return "AWS4-HMAC-SHA256 Credential=" + access_key + "/" + scope + ", " + 102 | "SignedHeaders=" + signed_headers + ", " + "Signature=" + signature; 103 | } 104 | 105 | utils::Multimap SignV4(const std::string& service_name, http::Method method, 106 | const std::string& uri, const std::string& region, 107 | utils::Multimap& headers, utils::Multimap query_params, 108 | const std::string& access_key, 109 | const std::string& secret_key, 110 | const std::string& content_sha256, 111 | const utils::UtcTime& date) { 112 | std::string scope = GetScope(date, region, service_name); 113 | 114 | std::string signed_headers; 115 | std::string canonical_headers; 116 | headers.GetCanonicalHeaders(signed_headers, canonical_headers); 117 | 118 | std::string canonical_query_string = query_params.GetCanonicalQueryString(); 119 | 120 | std::string methodstring = http::MethodToString(method); 121 | std::string canonical_request_hash = GetCanonicalRequestHash( 122 | methodstring, uri, canonical_query_string, canonical_headers, 123 | signed_headers, content_sha256); 124 | 125 | std::string string_to_sign = 126 | GetStringToSign(date, scope, canonical_request_hash); 127 | 128 | std::string signing_key = 129 | GetSigningKey(secret_key, date, region, service_name); 130 | 131 | std::string signature = GetSignature(signing_key, string_to_sign); 132 | 133 | std::string authorization = 134 | GetAuthorization(access_key, scope, signed_headers, signature); 135 | 136 | headers.Add("Authorization", authorization); 137 | return headers; 138 | } 139 | 140 | utils::Multimap SignV4S3(http::Method method, const std::string& uri, 141 | const std::string& region, utils::Multimap& headers, 142 | utils::Multimap query_params, 143 | const std::string& access_key, 144 | const std::string& secret_key, 145 | const std::string& content_sha256, 146 | const utils::UtcTime& date) { 147 | std::string service_name = "s3"; 148 | return SignV4(service_name, method, uri, region, headers, 149 | std::move(query_params), access_key, secret_key, content_sha256, 150 | date); 151 | } 152 | 153 | utils::Multimap SignV4STS(http::Method method, const std::string& uri, 154 | const std::string& region, utils::Multimap& headers, 155 | utils::Multimap query_params, 156 | const std::string& access_key, 157 | const std::string& secret_key, 158 | const std::string& content_sha256, 159 | const utils::UtcTime& date) { 160 | std::string service_name = "sts"; 161 | return SignV4(service_name, method, uri, region, headers, 162 | std::move(query_params), access_key, secret_key, content_sha256, 163 | date); 164 | } 165 | 166 | utils::Multimap PresignV4(http::Method method, const std::string& host, 167 | const std::string& uri, const std::string& region, 168 | utils::Multimap& query_params, 169 | const std::string& access_key, 170 | const std::string& secret_key, 171 | const utils::UtcTime& date, unsigned int expires) { 172 | std::string service_name = "s3"; 173 | std::string scope = GetScope(date, region, service_name); 174 | std::string canonical_headers = "host:" + host; 175 | std::string signed_headers = "host"; 176 | 177 | query_params.Add("X-Amz-Algorithm", "AWS4-HMAC-SHA256"); 178 | query_params.Add("X-Amz-Credential", access_key + "/" + scope); 179 | query_params.Add("X-Amz-Date", date.ToAmzDate()); 180 | query_params.Add("X-Amz-Expires", std::to_string(expires)); 181 | query_params.Add("X-Amz-SignedHeaders", signed_headers); 182 | std::string canonical_query_string = query_params.GetCanonicalQueryString(); 183 | std::string methodstring = http::MethodToString(method); 184 | std::string content_sha256 = "UNSIGNED-PAYLOAD"; 185 | std::string canonical_request_hash = GetCanonicalRequestHash( 186 | methodstring, uri, canonical_query_string, canonical_headers, 187 | signed_headers, content_sha256); 188 | 189 | std::string string_to_sign = 190 | GetStringToSign(date, scope, canonical_request_hash); 191 | std::string signing_key = 192 | GetSigningKey(secret_key, date, region, service_name); 193 | std::string signature = GetSignature(signing_key, string_to_sign); 194 | query_params.Add("X-Amz-Signature", signature); 195 | return query_params; 196 | } 197 | 198 | std::string PostPresignV4(const std::string& string_to_sign, 199 | const std::string& secret_key, 200 | const utils::UtcTime& date, 201 | const std::string& region) { 202 | std::string service_name = "s3"; 203 | std::string signing_key = 204 | GetSigningKey(secret_key, date, region, service_name); 205 | return GetSignature(signing_key, string_to_sign); 206 | } 207 | 208 | } // namespace minio::signer 209 | -------------------------------------------------------------------------------- /src/sse.cc: -------------------------------------------------------------------------------- 1 | // MinIO C++ Library for Amazon S3 Compatible Cloud Storage 2 | // Copyright 2022-2024 MinIO, Inc. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | // SPDX-License-Identifier: Apache-2.0 17 | 18 | #include "miniocpp/sse.h" 19 | 20 | #include 21 | 22 | #include "miniocpp/utils.h" 23 | 24 | namespace minio::s3 { 25 | 26 | Sse::Sse() {} 27 | 28 | Sse::~Sse() {} 29 | 30 | utils::Multimap Sse::Headers() const { return headers_; } 31 | 32 | utils::Multimap Sse::CopyHeaders() const { return copy_headers_; } 33 | 34 | SseCustomerKey::SseCustomerKey(std::string_view key) { 35 | std::string b64key = utils::Base64Encode(key); 36 | std::string md5key = utils::Md5sumHash(key); 37 | 38 | headers_.Add("X-Amz-Server-Side-Encryption-Customer-Algorithm", "AES256"); 39 | headers_.Add("X-Amz-Server-Side-Encryption-Customer-Key", b64key); 40 | headers_.Add("X-Amz-Server-Side-Encryption-Customer-Key-MD5", md5key); 41 | 42 | copy_headers_.Add( 43 | "X-Amz-Copy-Source-Server-Side-Encryption-Customer-Algorithm", "AES256"); 44 | copy_headers_.Add("X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key", 45 | b64key); 46 | copy_headers_.Add("X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key-MD5", 47 | md5key); 48 | } 49 | 50 | SseCustomerKey::~SseCustomerKey() {} 51 | 52 | bool SseCustomerKey::TlsRequired() const { return true; } 53 | 54 | SseKms::SseKms(std::string_view key, std::string_view context) { 55 | headers_.Add("X-Amz-Server-Side-Encryption-Aws-Kms-Key-Id", std::string(key)); 56 | headers_.Add("X-Amz-Server-Side-Encryption", "aws:kms"); 57 | if (!context.empty()) { 58 | headers_.Add("X-Amz-Server-Side-Encryption-Context", 59 | utils::Base64Encode(context)); 60 | } 61 | } 62 | 63 | SseKms::~SseKms() {} 64 | 65 | bool SseKms::TlsRequired() const { return true; } 66 | 67 | SseS3::SseS3() { headers_.Add("X-Amz-Server-Side-Encryption", "AES256"); } 68 | 69 | SseS3::~SseS3() {} 70 | 71 | bool SseS3::TlsRequired() const { return false; } 72 | 73 | } // namespace minio::s3 -------------------------------------------------------------------------------- /tests/private.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEAupkiVeaM9e9fj/xtV9O2OB6U0mUf0wuZRwGIdmMXnDr7rkBw 3 | WAoI120gZkUF7j0WSMvJlwGuposLLBoEpTCmh+mVf7PNlYgkn+E49VvaJ9Q7w/Gz 4 | YAlbNGmANg5mzsnkskMsh9+UyyGmdgvX1EQK4sQ3Hq7FIyzL/xm6y9qNiGvseLwU 5 | hKlBF5X7O5wNY25tH2KCpXMY57w5pCGAQnTKjb3hwwy18wrlyquGjC5TPtbPIeUo 6 | VQIcaQs2N8Z3HzrwBgNSVlYxLDFHfD0OPivPCSlSBh9x2Zi9HsYzReCrO6HCDakC 7 | ZO0WNGVCXNdCZwoHZGOW5x7his4+A3at02uRawIDAQABAoIBAElz2mZCGR7+mXmO 8 | fmRiPIqezyp7ECn9mNqwqc0geLzRIx2W1CJz4MMce/KGHS2I8mq5faNp0BxTA5Ta 9 | sRVtr0A1HNpmJvlD3FbrS4aaH6gqDVS2okudoz9ggE3HIYUpSFM7yh26T1Ie7u3s 10 | /4rZNgfKAYCcf5G3Ip5KvJNedvRKC2w5UX4iYU5eMuXs0YPy2+DtTKxZKIEnI3x4 11 | VpMe652I7GhjkLSsyuW5NoDeSWmmqhitm1bibuZQBR0ogFyAU94rZk8+j4hiUl9k 12 | 7ZVi00tKNp7EcLIwbY02ZCpZ2xvat8W1SLeWRUpExPj/7nnA9Fafrl5M8aHgl8R1 13 | N0Fd+zECgYEA4GruRDPPNPEXPByes6jjcxfvdoYIDyma1V+FN5Nn+/QPL/vWp9t0 14 | +mH344iwWkEyZZHNUpNuy5dpOA9724iFFLp9Btq06OgzzDuJj1LDbDpB4zwltuQA 15 | 4s7ekTFi9rHDOeAyTREHgDu3uya/2qq53Ms6w8gXM4/kmp9/S4N5VhcCgYEA1Nuv 16 | J1khBitNiNbzHYG9DRV4HLfIB8FFDKtgnW8HvSaWUtHKI4YitwJVFfa5Epz9MDFy 17 | tkFAD9Bu0HqZQ6OQZxGo0rDUcFics9Ftw+w3p/PIocPQBK7PNQ3L9BQS9M3stL+k 18 | fW5r+kUvfZaJVE8agCQQnzkJJh9oexJjMWyxB80CgYBa5BQSPWWLjKWba//+xcUx 19 | BR2wREKZWYFjL+e1hZcU3VkVVwsuOtza17jdR6wdMdCmgHHHIv05qd4snWDNnjJA 20 | HfOrRgMFXZ409lwVVzDc8Y9j6CViOF//fEd6SKVLQt3N3/afbek6z3TvcJc9ie3y 21 | 9cCcMLrs4Dd3RGf6/omzCwKBgQChwWxCf6Xr9T5PjeFke/I5niYP1M2KryGU9itO 22 | mFCOOmOj/k8ZXdbFsl0Meti7v1dcp0cgH0fafK+peHE+CG81FCNyMPTPh1dWAwHi 23 | EIFe/ZBq9c3/sQQ/sgNasWKSbGbEGJqcwywFHUxwqNQloJNn64BCL2q3cMjKNffx 24 | WELTxQKBgQDe7adrUBtk8+YZ1/c2VsV1oBq6eI2U+1bWa/8fwXWd9ylETBMtcv20 25 | Fs8UAFWLz78aWaXWWSSEmFvUbjXPBDvzXCObb6HdhXOCF1n74hKU+z06MAUa1eFC 26 | V0GvBx4v1rc1pZ7grBZwGteeVWVgCAZ487m5TATWqxuarH6yfU0Ptg== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /tests/public.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDojCCAoqgAwIBAgIUHE3HUt7gKVBp7wT9Hjj4wRT1xywwDQYJKoZIhvcNAQEL 3 | BQAwejELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRgwFgYDVQQHDA9jdXN0b20t 4 | bG9jYXRpb24xHDAaBgNVBAoME2N1c3RvbS1vcmdhbml6YXRpb24xEjAQBgNVBAsM 5 | CWN1c3RvbS1vdTESMBAGA1UEAwwJbG9jYWxob3N0MCAXDTIxMDkyMDEyMTAyOFoY 6 | DzIxMjEwODI3MTIxMDI4WjB6MQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExGDAW 7 | BgNVBAcMD2N1c3RvbS1sb2NhdGlvbjEcMBoGA1UECgwTY3VzdG9tLW9yZ2FuaXph 8 | dGlvbjESMBAGA1UECwwJY3VzdG9tLW91MRIwEAYDVQQDDAlsb2NhbGhvc3QwggEi 9 | MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6mSJV5oz171+P/G1X07Y4HpTS 10 | ZR/TC5lHAYh2YxecOvuuQHBYCgjXbSBmRQXuPRZIy8mXAa6miwssGgSlMKaH6ZV/ 11 | s82ViCSf4Tj1W9on1DvD8bNgCVs0aYA2DmbOyeSyQyyH35TLIaZ2C9fURArixDce 12 | rsUjLMv/GbrL2o2Ia+x4vBSEqUEXlfs7nA1jbm0fYoKlcxjnvDmkIYBCdMqNveHD 13 | DLXzCuXKq4aMLlM+1s8h5ShVAhxpCzY3xncfOvAGA1JWVjEsMUd8PQ4+K88JKVIG 14 | H3HZmL0exjNF4Ks7ocINqQJk7RY0ZUJc10JnCgdkY5bnHuGKzj4Ddq3Ta5FrAgMB 15 | AAGjHjAcMBoGA1UdEQQTMBGHBH8AAAGCCWxvY2FsaG9zdDANBgkqhkiG9w0BAQsF 16 | AAOCAQEAREoEGX34C0+osOgCPwZ4mFXVvssJRJTc4JL/kqOGPyzS/085MzeIpOhu 17 | gkOm3zj175SKiZMWWpYhB+Q/1T6tDiVLidEY7HK/dcbjYfoTAd42cQWY4qmG68vG 18 | E6WnTQjal0uPuCwKqvqIRgkWLpaIV4TmHtpCFLLlVlnDWQBpAdiK/Vk0EeTDDaqd 19 | cROr4tm/8EBxqwUnIQF8vgbXgVT5BNdcp44LWs7A558CCRrCGifch5+kxkSSdAFG 20 | Y7BEXvnnsxU1n9AAVKJYnp1wUN2Hk4KWyPcQb9/Ee45DKDR5KNyMqClsWWXMJr40 21 | FrgI6euT50Wzo8Qqbls5Bt/0IzObnA== 22 | -----END CERTIFICATE----- 23 | -------------------------------------------------------------------------------- /vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minio-cpp", 3 | "version": "0.3.0", 4 | "description": "The MinIO C++ Client SDK provides simple APIs to access any Amazon S3 compatible object storage", 5 | "homepage": "https://github.com/minio/minio-cpp", 6 | "license": "Apache-2.0", 7 | "dependencies": [ 8 | { "name": "curlpp" }, 9 | { "name": "inih", "features": ["cpp"] }, 10 | { "name": "nlohmann-json" }, 11 | { "name": "openssl" }, 12 | { "name": "pugixml" }, 13 | { "name": "zlib", "platform": "windows" }, 14 | { "name": "vcpkg-cmake", "host": true }, 15 | { "name": "vcpkg-cmake-config", "host": true } 16 | ] 17 | } 18 | --------------------------------------------------------------------------------