GithubHelp home page GithubHelp logo

marinehuang / aliyun-oss-cpp-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aliyun/aliyun-oss-cpp-sdk

0.0 1.0 0.0 5.17 MB

Aliyun OSS SDK for C++

License: Other

CMake 0.55% C++ 99.34% C 0.12%

aliyun-oss-cpp-sdk's Introduction

Alibaba Cloud OSS C++ Software Development Kit

中文文档

Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring massive capacity, security, a low cost, and high reliability. You can upload and download data on any application anytime and anywhere by calling APIs, and perform simple management of data through the web console. The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.

The OSS SDK for C++ provides a variety of modern C++ (version C++ 11 or later) interfaces for convenient use of the OSS.

This document introduces how to obtain and call Alibaba Cloud OSS C++ SDK.

If you have any problem while using C++ SDK, please contact us.

Prerequisites

To use Alibaba Cloud OSS C++ SDK, you must:

  • Have an Alibaba Cloud account and an AccessKey. The AccessKey is required when initializing the client. You can create an AccessKey in the Alibaba Cloud console. For more information, see Create an AccessKey

Note: To increase the security of your account, we recommend that you use the AccessKey of the RAM user to access Alibaba Cloud services.

  • Install a compiler that supports C + + 11 or later:
    • Visual Studio 2013 or later:
    • or GCC 4.8 or later:
    • or Clang 3.3 or later:

Building the SDK

  1. Download or clone from GitHub aliyun-oss-cpp-sdk
git clone https://github.com/aliyun/aliyun-oss-cpp-sdk.git
  1. Install CMake 3.1 or later, enter SDK to create build files required for the build
cd <path/to/aliyun-oss-cpp-sdk>
mkdir build
cd build
cmake ..

Windows

Enter build folder, open alibabacloud-oss-cpp-sdk.sln with Visual Studio.

Or run the the following commands to build and install:

msbuild ALL_BUILD.vcxproj
msbuild INSTALL.vcxproj

Linux

Install third-party libraries on the Linux platform, including libcurl and libopenssl.

Run the following commands on the Redhat/Fedora system to install third-party libraries.

sudo dnf install libcurl-devel openssl-devel

Run the following commands on the Debian/Ubuntu system to install third-party libraries.

sudo apt-get install libcurl4-openssl-dev libssl-dev

Run the following commands to build and install sdk:

make
sudo make install

Mac

On Mac you should specify openssl path. For example, openssl is installed in /usr/local/Cellar/openssl/1.0.2p, run the following commands

cmake -DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl/1.0.2p  \
      -DOPENSSL_LIBRARIES=/usr/local/Cellar/openssl/1.0.2p/lib  \
      -DOPENSSL_INCLUDE_DIRS=/usr/local/Cellar/openssl/1.0.2p/include/ ..
make

Android

Build and install third-party libraries, including libcurl and libopenssl to $ANDROID_NDK/sysroot, run the following commands

cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake  \
      -DANDROID_NDK=$ANDROID_NDK    \
      -DANDROID_ABI=armeabi-v7a     \
      -DANDROID_TOOLCHAIN=clang     \
      -DANDROID_PLATFORM=android-21 \
      -DANDROID_STL=c++_shared ..
make

CMake Option

BUILD_SHARED_LIBS

(Default OFF) If turned on, both static and shared libraries are built, and the static library name has a -static suffix. At the same time, the sample project will be linked to the shared library.

cmake .. -DBUILD_SHARED_LIBS=ON

BUILD_TESTS

(Default OFF) If turned on, both test and ptest project will be built.

cmake .. -DBUILD_TESTS=ON

ENABLE_RTTI

(Default ON) If turned off, the SDK is built without RTTI information.

cmake .. -DENABLE_RTTI=OFF

OSS_DISABLE_BUCKET

(Default OFF) If turned ON, the SDK is built without the bucket's API.

cmake .. -DOSS_DISABLE_BUCKET=ON

OSS_DISABLE_LIVECHANNEL

(Default OFF) If turned ON, the SDK is built without the livechannel's API.

cmake .. -DOSS_DISABLE_LIVECHANNEL=ON

OSS_DISABLE_RESUAMABLE

(Default OFF) If turned ON, the SDK is built without the resumable operation feature.

cmake .. -DOSS_DISABLE_RESUAMABLE=ON

OSS_DISABLE_ENCRYPTION

(Default OFF) If turned ON, the SDK is built without the client-side encryption feature.

cmake .. -DOSS_DISABLE_ENCRYPTION=ON

Use the C++ SDK

The following code shows how to list buckets owned by the requester.

Note: Please replace the your-region-id,your-access-key-id and your-access-key-secret in the sample.

#include <alibabacloud/oss/OssClient.h>
using namespace AlibabaCloud::OSS;

int main(int argc, char** argv)
{
    // Initialize the SDK
    InitializeSdk();

    // Configure the instance
    ClientConfiguration conf;
    OssClient client("your-region-id", "your-access-key-id", "your-access-key-secret", conf);

    // Create an API request
    ListBucketsRequest request;
    auto outcome = client.ListBuckets(request);
    if (!outcome.isSuccess()) {
        // Handle exceptions
        std::cout << "ListBuckets fail" <<
            ",code:" << outcome.error().Code() <<
            ",message:" << outcome.error().Message() <<
            ",requestId:" << outcome.error().RequestId() << std::endl;
        ShutdownSdk();
        return -1;
    }

    // Close the SDK
    ShutdownSdk();
    return 0;
}

License

See the LICENSE file (Apache 2.0 license).

aliyun-oss-cpp-sdk's People

Contributors

funrily avatar huiguangjun avatar leeyiw avatar marinehuang avatar yi-liu9 avatar

Watchers

 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.