从内存中上传数据

实现在内存中上传数据到指定文件(Object),最大文件(Object)不能超过5GB。代码中需要引用"inspurcloud/oss/OssClient.h"类库、使用InspurCloud::OSS命名空间,并初始化账号信息AccessKeyId、AccessKeySecret、Endpoint,示例代码:

        //指定上传到的存储桶以及目标文件(Object),"yourObjectName"需包含文件后缀名,例如abc/efg/inspur.txt
        std::string BucketName = "yourBucketName";
        std::string ObjectName = "yourObjectName"; 

        //初始化资源
        InitializeSdk();
        ClientConfiguration conf;
        OssClient client(Endpoint, AccessKeyId, AccessKeySecret, conf);
        std::shared_ptr<std::iostream> content = std::make_shared<std::stringstream>();
        *content << "Welcome to Inspur Cloud Object Storage Service!";
        PutObjectRequest request(BucketName, ObjectName, content);

        //上传文件
        auto outcome = client.PutObject(request);

        //处理结果
        if (!outcome.isSuccess()) {
            std::cout << "PutObject fail" <<std::endl;
            std::cout <<"error code:" << outcome.error().Code() <<std::endl;
            std::cout <<"error message:" << outcome.error().Message() <<std::endl;
            std::cout <<"requestId:" << outcome.error().RequestId() << std::endl;
            ShutdownSdk();
            return -1;
        }
        else{
            std::cout << "PutObject Success!" << std::endl;
        }

        //释放资源
        ShutdownSdk();