Git Product home page Git Product logo

minio-cpp-sdk's Introduction

minio-cpp-sdk

该项目提供 Minio C++ 版本的 SDK。使用方式和 Minio 官方提供的版本类似, 使用方便,使用时无外部依赖。用户可以查看 Minio 官网 查看所有 API 用法。

安装 SDK

你可以使用源码进行编译,也可以使用我们预编译好的包使用。预编译包地址

脚本安装

执行在根目录下的 install.sh 文件安装 Minio C++ SDK.

chmod +x install.sh
./install.sh

源码编译

Minio C++ SDK 是基于 AWS S3 的 SDK 二次开发的,因此在源码编译 SDK 前我们需要安装 aws-sdk-cpp。

下载 aws-sdk-cpp

git clone https://github.com/congjiye/minio-cpp-sdk.git
cd minio-cpp-sdk
git submodule update --init --recursive

安装依赖

sudo apt-get install libcurl4-openssl-dev libssl-dev uuid-dev zlib1g-dev libpulse-dev

编译 aws-sdk-cpp

用户可以根据自行需要选择使用 release 或者 debug 版本。通过修改 -DCMAKE_BUILD_TYPE 选择编译版本。用户可以通过修改 -DCMAKE_PREFIX_INSTALL 来设置安装目录。

CMAKE 选项 说明 参数
-DCMAKE_BUILD_TYPE 编译版本 Release / Debug
-DBUILD_SHARED_LIBS 编译动态或静态库 OFF / ON
-DCMAKE_INSTALL_PREFIX 编译后安装目录 安装目录,默认为 /usr/local
cd aws-sdk-cpp

# Release 版本
mkdir cmake-build-release
cd cmake-build-release
cmake -DBUILD_ONLY="s3" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=<you-install-path> ..
make
make install

# Debug 版本
mkdir cmake-build-debug
cd cmake-build-debug
cmake -DBUILD_ONLY="s3" -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=<you-install-path> ..
make
make install

编译 minio-cpp-sdk

用户可以通过修改 -DAWSSDK_ROOT_DIR 来设置安装目录,默认目录为当前源码文件下的 install 文件夹。

cd minio-cpp-sdk
mkdir build && cd build

# 如果 aws-sdk-cpp 选择了自定义安装路径,则使用如下命令
# cmake -DAWSSDK_ROOT_DIR=../aws-sdk-cpp/path/to/your/custom/install ..

cmake ..
make && make install

如何使用

所有接口方法都有相应的注释,用户可以自行查看 minio.h 文件查看相应的接口使用方法。

CMAKE 使用

# 方式一
include_directories("your-install-path/minio/include")
link_directories("your-install-path/minio/lib)
target_link_libraries(project PRIVATE minio)

# 方式二
set(Minio_CPP_ROOT_DIR "your-install-path/lib/cmake")
target_link_libraries(target ${Minio_CPP_LIBRARIES})
target_include_directories(target PUBLIC ${Minio_CPP_INCLUDE_DIRS})

下载文件

#include "minio.h"

int main()
{
    Minio::Minio minio("play.min.io",
                       "Q3AM3UQ867SPQQA43P2F",
                       "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
    try
    {
        minio.GetObject("lib", "word.txt", "word.txt");
    }
    catch (const Minio::MinioException &e)
    {
        std::cerr << e.what() << std::endl;
    }
    return 0;
}

测试

目前接口使用 valgrind 进行测试。下载文件接口已通过测试,可以放心使用。

TODO

  • 完善所有接口实现
  • 并行接口测试

minio-cpp-sdk's People

Contributors

congjiye avatar superxh avatar

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.