initial commit
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
#ifndef BASE_OP_H
|
||||
#define BASE_OP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "cos_config.h"
|
||||
#include "op/cos_result.h"
|
||||
|
||||
namespace qcloud_cos{
|
||||
|
||||
class BaseReq;
|
||||
class BaseResp;
|
||||
|
||||
class BaseOp {
|
||||
public:
|
||||
/// \brief BaseOp构造函数
|
||||
///
|
||||
/// \param cos_conf Cos配置
|
||||
explicit BaseOp(const SharedConfig& cos_conf)
|
||||
: m_config(cos_conf) {
|
||||
}
|
||||
|
||||
BaseOp() {}
|
||||
|
||||
/// \brief BaseOp析构函数
|
||||
~BaseOp() {}
|
||||
|
||||
/// \brief 获取Cos配置
|
||||
CosConfig GetCosConfig() const;
|
||||
|
||||
/// \brief 获取AppID
|
||||
uint64_t GetAppId() const;
|
||||
|
||||
/// \brief 获取AccessKey
|
||||
std::string GetAccessKey() const;
|
||||
|
||||
/// \brief 获取SecretKey
|
||||
std::string GetSecretKey() const;
|
||||
|
||||
/// \brief 获取Token
|
||||
std::string GetTmpToken() const;
|
||||
|
||||
/// \brief 封装了cos Service/Bucket/Object 相关接口的通用操作,
|
||||
/// 包括签名计算、请求发送、返回内容解析等
|
||||
///
|
||||
/// \param host 目标主机, 以http://开头
|
||||
/// \param path http path
|
||||
/// \param req http请求
|
||||
/// \param req_body http request的body
|
||||
/// \param resp http返回
|
||||
///
|
||||
/// \return http调用情况(状态码等)
|
||||
CosResult NormalAction(const std::string& host,
|
||||
const std::string& path,
|
||||
const BaseReq& req,
|
||||
const std::string& req_body,
|
||||
bool check_body,
|
||||
BaseResp* resp);
|
||||
|
||||
/// \brief 封装了cos Service/Bucket/Object相关接口的通用操作,
|
||||
/// 包括签名计算、请求发送、返回内容解析等
|
||||
///
|
||||
/// \param host 目标主机, 以http://开头
|
||||
/// \param path http path
|
||||
/// \param req http请求
|
||||
/// \param additional_headers http请求需要所需的额外header
|
||||
/// \param additional_params http请求需要所需的额外params
|
||||
/// \param req_body http request的body
|
||||
/// \param resp http返回
|
||||
///
|
||||
/// \return http调用情况(状态码等)
|
||||
CosResult NormalAction(const std::string& host,
|
||||
const std::string& path,
|
||||
const BaseReq& req,
|
||||
const std::map<std::string, std::string>& additional_headers,
|
||||
const std::map<std::string, std::string>& additional_params,
|
||||
const std::string& req_body,
|
||||
bool check_body,
|
||||
BaseResp* resp);
|
||||
|
||||
/// \brief 下载文件并输出到流中
|
||||
///
|
||||
/// \param host 目标主机, 以http://开头
|
||||
/// \param path http path
|
||||
/// \param req http请求
|
||||
/// \param resp http返回
|
||||
/// \param os 输出流
|
||||
///
|
||||
/// \return http调用情况(状态码等)
|
||||
CosResult DownloadAction(const std::string& host,
|
||||
const std::string& path,
|
||||
const BaseReq& req,
|
||||
BaseResp* resp,
|
||||
std::ostream& os);
|
||||
|
||||
/// \brief 支持从stream中读入数据并上传
|
||||
///
|
||||
/// \param host 目标主机, 以http://开头
|
||||
/// \param path http path
|
||||
/// \param req http请求
|
||||
/// \param additional_headers http请求需要所需的额外header
|
||||
/// \param additional_params http请求需要所需的额外params
|
||||
/// \param is http request的body
|
||||
/// \param resp http返回
|
||||
///
|
||||
/// \return http调用情况(状态码等)
|
||||
CosResult UploadAction(const std::string& host,
|
||||
const std::string& path,
|
||||
const BaseReq& req,
|
||||
const std::map<std::string, std::string>& additional_headers,
|
||||
const std::map<std::string, std::string>& additional_params,
|
||||
std::istream& is,
|
||||
BaseResp* resp);
|
||||
|
||||
std::string GetRealUrl(const std::string& host,
|
||||
const std::string& path,
|
||||
bool is_https);
|
||||
|
||||
|
||||
protected:
|
||||
SharedConfig m_config;
|
||||
};
|
||||
|
||||
} // namespace qcloud_cos
|
||||
#endif
|
||||
@@ -0,0 +1,380 @@
|
||||
// Copyright (c) 2017, Tencent Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Author: sevenyou <sevenyou@tencent.com>
|
||||
// Created: 07/13/17
|
||||
// Description:
|
||||
|
||||
#ifndef BUCKETOP_H
|
||||
#define BUCKETOP_H
|
||||
#pragma once
|
||||
|
||||
#include "cos_sys_config.h"
|
||||
#include "op/base_op.h"
|
||||
#include "op/cos_result.h"
|
||||
#include "request/bucket_req.h"
|
||||
#include "response/bucket_resp.h"
|
||||
#include "request/data_process_req.h"
|
||||
#include "response/data_process_resp.h"
|
||||
|
||||
namespace qcloud_cos {
|
||||
|
||||
/// \brief 封装了Bucket相关的操作
|
||||
class BucketOp : public BaseOp {
|
||||
public:
|
||||
/// \brief BucketOp构造函数
|
||||
///
|
||||
/// \param cos_conf Cos配置
|
||||
explicit BucketOp(const SharedConfig& config) : BaseOp(config) {}
|
||||
|
||||
/// \brief BucketOp析构函数
|
||||
virtual ~BucketOp() {}
|
||||
|
||||
/// \brief 判断bucket是否存在
|
||||
bool IsBucketExist(const std::string& bucket_name);
|
||||
|
||||
/// \brief 获取Bucket所在Location
|
||||
std::string GetBucketLocation(const std::string& bucket_name);
|
||||
|
||||
/// \brief 创建一个Bucket
|
||||
/// (详见:https://www.qcloud.com/document/product/436/7738)
|
||||
///
|
||||
/// \param req PutBucket请求
|
||||
/// \param resp PutBucket返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucket(const PutBucketReq& req, PutBucketResp* resp);
|
||||
|
||||
/// \brief 确认Bucket是否存在
|
||||
/// (详见:https://cloud.tencent.com/document/product/436/7735)
|
||||
///
|
||||
/// \param req HeadBucket请求
|
||||
/// \param resp HeadBucket返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult HeadBucket(const HeadBucketReq& req, HeadBucketResp* resp);
|
||||
|
||||
/// \brief 列出Bucket下的部分或者全部Object
|
||||
/// (详见:https://www.qcloud.com/document/product/436/7734)
|
||||
///
|
||||
/// \param req GetBucket请求
|
||||
/// \param resp GetBucket返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucket(const GetBucketReq& req, GetBucketResp* resp);
|
||||
|
||||
CosResult ListMultipartUpload(const ListMultipartUploadReq& req, ListMultipartUploadResp* resp);
|
||||
/// \brief 删除Bucket
|
||||
///
|
||||
/// \param req DeleteBucket请求
|
||||
/// \param resp DeleteBucket返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult DeleteBucket(const DeleteBucketReq& req, DeleteBucketResp* resp);
|
||||
|
||||
/// \brief 获得存储桶的版本控制信息
|
||||
/// (详见:https://cloud.tencent.com/document/product/436/8597)
|
||||
///
|
||||
/// \param req GetBucketVersioning请求
|
||||
/// \param resp GetBucketVersioning返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketVersioning(const GetBucketVersioningReq& req,
|
||||
GetBucketVersioningResp* resp);
|
||||
|
||||
/// \brief 启用或者暂停存储桶的版本控制功能
|
||||
/// (详见:https://cloud.tencent.com/document/product/436/8591)
|
||||
///
|
||||
/// \param req PutBucketVersioning请求
|
||||
/// \param resp PutBucketVersioning返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketVersioning(const PutBucketVersioningReq& req,
|
||||
PutBucketVersioningResp* resp);
|
||||
|
||||
/// \brief 列出Bucket下的跨域复制配置
|
||||
///
|
||||
/// \param req GetBucketReplication请求
|
||||
/// \param resp GetBucketReplication返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketReplication(const GetBucketReplicationReq& req,
|
||||
GetBucketReplicationResp* resp);
|
||||
|
||||
/// \brief 增加/替换Bucket下的跨域复制配置
|
||||
///
|
||||
/// \param req PutBucketReplication请求
|
||||
/// \param resp PutBucketReplication返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketReplication(const PutBucketReplicationReq& req,
|
||||
PutBucketReplicationResp* resp);
|
||||
|
||||
/// \brief 删除Bucket下的跨域复制配置
|
||||
///
|
||||
/// \param req DeleteBucketReplication请求
|
||||
/// \param resp DeleteBucketReplication返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult DeleteBucketReplication(const DeleteBucketReplicationReq& req,
|
||||
DeleteBucketReplicationResp* resp);
|
||||
|
||||
/// \brief 列出Bucket下的生命周期配置
|
||||
///
|
||||
/// \param req GetBucketLifecycle请求
|
||||
/// \param resp GetBucketLifecycle返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketLifecycle(const GetBucketLifecycleReq& req,
|
||||
GetBucketLifecycleResp* resp);
|
||||
|
||||
/// \brief 增加/替换Bucket下的生命周期配置
|
||||
///
|
||||
/// \param req PutBucketLifecycle请求
|
||||
/// \param resp PutBucketLifecycle返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketLifecycle(const PutBucketLifecycleReq& req,
|
||||
PutBucketLifecycleResp* resp);
|
||||
|
||||
/// \brief 删除Bucket下的生命周期配置
|
||||
///
|
||||
/// \param req DeleteBucketLifecycle请求
|
||||
/// \param resp DeleteBucketLifecycle返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult DeleteBucketLifecycle(const DeleteBucketLifecycleReq& req,
|
||||
DeleteBucketLifecycleResp* resp);
|
||||
|
||||
/// \brief 列出Bucket下的ACL
|
||||
///
|
||||
/// \param req GetBucketACL请求
|
||||
/// \param resp GetBucketACL返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketACL(const GetBucketACLReq& req,
|
||||
GetBucketACLResp* resp);
|
||||
|
||||
/// \brief 增加/替换Bucket下的ACL, 可以通过Header或者Body传入ACL信息
|
||||
/// 注意Header 和 Body 只能选择其中一种,否则响应返回会冲突
|
||||
///
|
||||
/// \param req PutBucketACL请求
|
||||
/// \param resp PutBucketACL返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketACL(const PutBucketACLReq& req,
|
||||
PutBucketACLResp* resp);
|
||||
|
||||
/// \brief 列出Bucket下的CORS
|
||||
///
|
||||
/// \param req GetBucketCORS请求
|
||||
/// \param resp GetBucketCORS返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketCORS(const GetBucketCORSReq& req,
|
||||
GetBucketCORSResp* resp);
|
||||
|
||||
/// \brief 增加/替换Bucket下的CORS
|
||||
///
|
||||
/// \param req PutBucketCORS请求
|
||||
/// \param resp PutBucketCORS返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketCORS(const PutBucketCORSReq& req,
|
||||
PutBucketCORSResp* resp);
|
||||
|
||||
/// \brief 删除Bucket下的CORS
|
||||
///
|
||||
/// \param req DeleteBucketCORS请求
|
||||
/// \param resp DeleteBucketCORS返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult DeleteBucketCORS(const DeleteBucketCORSReq& req,
|
||||
DeleteBucketCORSResp* resp);
|
||||
|
||||
/// \brief 列出Bucket下的部分或者全部Object(包括多版本)
|
||||
///
|
||||
/// \param req GetBucketObjectVersions请求
|
||||
/// \param resp GetBucketObjectVersions返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketObjectVersions(const GetBucketObjectVersionsReq& req,
|
||||
GetBucketObjectVersionsResp* resp);
|
||||
|
||||
/// \brief 获取Bucket所在Location
|
||||
///
|
||||
/// \param req GetBucketLocation请求
|
||||
/// \param resp GetBucketLocation返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketLocation(const GetBucketLocationReq& req,
|
||||
GetBucketLocationResp* resp);
|
||||
// TODO(sevenyou)
|
||||
// std::string ListMultipartUploads();
|
||||
|
||||
|
||||
/// \brief 为源存储桶开启日志记录
|
||||
/// \brief https://cloud.tencent.com/document/product/436/17054
|
||||
/// \param req PutBucketLogging请求
|
||||
/// \param resp PutBucketLogging返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketLogging(const PutBucketLoggingReq& req,
|
||||
PutBucketLoggingResp* resp);
|
||||
|
||||
/// \brief 用于获取源存储桶的日志配置信息
|
||||
/// \brief https://cloud.tencent.com/document/product/436/17053
|
||||
/// \param req GetBucketLogging请求
|
||||
/// \param resp GetBucketLogging返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketLogging(const GetBucketLoggingReq& req,
|
||||
GetBucketLoggingResp* resp);
|
||||
|
||||
/// \brief 用于存储桶绑定自定义域名
|
||||
/// \brief
|
||||
/// \param req PutBucketDomain请求
|
||||
/// \param resp PutBucketDomain返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketDomain(const PutBucketDomainReq& req,
|
||||
PutBucketDomainResp* resp);
|
||||
|
||||
/// \brief 用于获取存储桶绑定自定义域名
|
||||
/// \brief
|
||||
/// \param req GetBucketDomain请求
|
||||
/// \param resp GetBucketDomain返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketDomain(const GetBucketDomainReq& req,
|
||||
GetBucketDomainResp* resp);
|
||||
|
||||
/// \brief 存储桶配置静态网站,通过传入 XML 格式的配置文件进行配置,文件大小限制为64KB
|
||||
/// \brief https://cloud.tencent.com/document/product/436/31930
|
||||
/// \param req PutBucketWebsite请求
|
||||
/// \param resp PutBucketWebsite返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketWebsite(const PutBucketWebsiteReq& req,
|
||||
PutBucketWebsiteResp* resp);
|
||||
|
||||
/// \brief 获取与存储桶关联的静态网站配置信息.
|
||||
/// \brief https://cloud.tencent.com/document/product/436/31929
|
||||
/// \param req GetBucketWebsite请求
|
||||
/// \param resp GetBucketWebsite返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketWebsite(const GetBucketWebsiteReq& req,
|
||||
GetBucketWebsiteResp* resp);
|
||||
|
||||
/// \brief 删除存储桶中的静态网站配置.
|
||||
/// \brief https://cloud.tencent.com/document/product/436/31928
|
||||
/// \param req DeleteBucketWebsite请求
|
||||
/// \param resp DeleteBucketWebsite返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult DeleteBucketWebsite(const DeleteBucketWebsiteReq& req,
|
||||
DeleteBucketWebsiteResp* resp);
|
||||
|
||||
/// \brief 为已存在的Bucket设置标签.
|
||||
/// \brief https://cloud.tencent.com/document/product/436/34838
|
||||
/// \param req PutBucketTagging请求
|
||||
/// \param resp PutBucketTagging返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketTagging(const PutBucketTaggingReq& req,
|
||||
PutBucketTaggingResp* resp);
|
||||
|
||||
|
||||
/// \brief 查询指定存储桶下已有的存储桶标签.
|
||||
/// \brief https://cloud.tencent.com/document/product/436/34837
|
||||
/// \param req GetBucketTagging请求
|
||||
/// \param resp GetBucketTagging返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketTagging(const GetBucketTaggingReq& req,
|
||||
GetBucketTaggingResp* resp);
|
||||
|
||||
/// \brief 删除指定存储桶下已有的存储桶标签.
|
||||
/// \brief https://cloud.tencent.com/document/product/436/34836
|
||||
/// \param req DeleteBucketTagging请求
|
||||
/// \param resp DeleteBucketTagging返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult DeleteBucketTagging(const DeleteBucketTaggingReq& req,
|
||||
DeleteBucketTaggingResp* resp);
|
||||
|
||||
/// \brief 用于在存储桶中创建清单任务.
|
||||
/// \brief https://cloud.tencent.com/document/product/436/33707
|
||||
/// \param req PutBucketinventory请求
|
||||
/// \param resp PutBucketinventory返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketInventory(const PutBucketInventoryReq& req,
|
||||
PutBucketInventoryResp* resp);
|
||||
|
||||
/// \brief 查询存储桶中用户的清单任务信息.
|
||||
/// \brief https://cloud.tencent.com/document/product/436/33705
|
||||
/// \param req GetBucketinventory请求
|
||||
/// \param resp GetBucketinventory返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketInventory(const GetBucketInventoryReq& req,
|
||||
GetBucketInventoryResp* resp);
|
||||
|
||||
/// \brief 请求返回一个存储桶中的所有清单任务.
|
||||
/// \brief https://cloud.tencent.com/document/product/436/33706
|
||||
/// \param req ListBucketInventoryConfigurations请求
|
||||
/// \param resp ListBucketInventoryConfigurations返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult ListBucketInventoryConfigurations(const ListBucketInventoryConfigurationsReq& req,
|
||||
ListBucketInventoryConfigurationsResp* resp);
|
||||
|
||||
/// \brief 用于删除存储桶中指定的清单任务.
|
||||
/// \brief https://cloud.tencent.com/document/product/436/33704
|
||||
/// \param req DeleteBucketinventory请求
|
||||
/// \param resp DeleteBucketinventory返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult DeleteBucketInventory(const DeleteBucketInventoryReq& req,
|
||||
DeleteBucketInventoryResp* resp);
|
||||
|
||||
/// \brief 列举直播通道
|
||||
/// \param req ListLiveChannelReq请求
|
||||
/// \param resp ListLiveChannelResp返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult ListLiveChannel(const ListLiveChannelReq& req, ListLiveChannelResp* resp);
|
||||
|
||||
/// \brief 配置存储桶智能分层
|
||||
///
|
||||
/// \param req PutBucketIntelligentTiering请求
|
||||
/// \param resp PutBucketIntelligentTiering返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutBucketIntelligentTiering(const PutBucketIntelligentTieringReq& req,
|
||||
PutBucketIntelligentTieringResp* resp);
|
||||
|
||||
/// \brief 获取存储桶智能分层配置
|
||||
///
|
||||
/// \param req GetBucketIntelligentTiering请求
|
||||
/// \param resp GetBucketIntelligentTiering返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetBucketIntelligentTiering(const GetBucketIntelligentTieringReq& req,
|
||||
GetBucketIntelligentTieringResp* resp);
|
||||
|
||||
CosResult CreateDocProcessJobs(const CreateDocProcessJobsReq& req, CreateDocProcessJobsResp* resp);
|
||||
|
||||
CosResult DescribeDocProcessJob(const DescribeDocProcessJobReq& req, DescribeDocProcessJobResp* resp);
|
||||
|
||||
CosResult DescribeDocProcessJobs(const DescribeDocProcessJobsReq& req, DescribeDocProcessJobsResp* resp);
|
||||
|
||||
CosResult DescribeDocProcessQueues(const DescribeDocProcessQueuesReq& req, DescribeDocProcessQueuesResp* resp);
|
||||
|
||||
CosResult UpdateDocProcessQueue(const UpdateDocProcessQueueReq& req, UpdateDocProcessQueueResp* resp);
|
||||
};
|
||||
|
||||
} // namespace qcloud_cos
|
||||
#endif // BUCKETOP_H
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright (c) 2017, Tencent Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Author: sevenyou <sevenyou@tencent.com>
|
||||
// Created: 07/25/17
|
||||
// Description:
|
||||
|
||||
#ifndef COS_RESULT_H
|
||||
#define COS_RESULT_H
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace qcloud_cos {
|
||||
|
||||
// 封装HTTP状态码:3XX,4XX,5XX 的返回结果
|
||||
// 详见官网链接: https://www.qcloud.com/document/product/436/7730
|
||||
class CosResult {
|
||||
public:
|
||||
CosResult()
|
||||
: m_is_succ(false), m_http_status(-1), m_error_info(""), m_err_code(""),
|
||||
m_err_msg(""), m_resource_addr(""), m_x_cos_request_id(""), m_x_cos_trace_id("") {}
|
||||
|
||||
~CosResult() {}
|
||||
|
||||
CosResult(const CosResult& other) {
|
||||
m_is_succ = other.m_is_succ;
|
||||
m_http_status = other.m_http_status;
|
||||
m_error_info = other.m_error_info;
|
||||
m_err_code = other.m_err_code;
|
||||
m_err_msg = other.m_err_msg;
|
||||
m_resource_addr = other.m_resource_addr;
|
||||
m_x_cos_request_id = other.m_x_cos_request_id;
|
||||
m_x_cos_trace_id = other.m_x_cos_trace_id;
|
||||
m_real_byte = other.m_real_byte;
|
||||
}
|
||||
|
||||
CosResult& operator=(const CosResult& other) {
|
||||
if (this != &other) {
|
||||
m_is_succ = other.m_is_succ;
|
||||
m_http_status = other.m_http_status;
|
||||
m_error_info = other.m_error_info;
|
||||
m_err_code = other.m_err_code;
|
||||
m_err_msg = other.m_err_msg;
|
||||
m_resource_addr = other.m_resource_addr;
|
||||
m_x_cos_request_id = other.m_x_cos_request_id;
|
||||
m_x_cos_trace_id = other.m_x_cos_trace_id;
|
||||
m_real_byte = other.m_real_byte;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool IsSucc() const { return m_is_succ; }
|
||||
void SetSucc() { m_is_succ = true; }
|
||||
void SetFail() { m_is_succ = false; }
|
||||
void Clear() {
|
||||
m_is_succ = false;
|
||||
m_http_status = -1;
|
||||
m_error_info = "";
|
||||
m_err_code = "";
|
||||
m_err_msg = "";
|
||||
m_resource_addr = "";
|
||||
m_x_cos_request_id = "";
|
||||
m_x_cos_trace_id = "";
|
||||
}
|
||||
|
||||
// 解析xml string
|
||||
bool ParseFromHttpResponse(const std::map<std::string, std::string>& headers,
|
||||
const std::string& body);
|
||||
|
||||
// Getter
|
||||
std::string GetErrorInfo() const { return m_error_info; }
|
||||
int GetHttpStatus() const { return m_http_status; }
|
||||
std::string GetErrorCode() const { return m_err_code; }
|
||||
std::string GetErrorMsg() const { return m_err_msg; }
|
||||
std::string GetResourceAddr() const { return m_resource_addr; }
|
||||
std::string GetXCosRequestId() const { return m_x_cos_request_id; }
|
||||
std::string GetXCosTraceId() const { return m_x_cos_trace_id; }
|
||||
std::string GetXCosServerTime() const { return m_x_cos_server_time; }
|
||||
uint64_t GetRealByte() const { return m_real_byte; }
|
||||
|
||||
// Setter
|
||||
void SetErrorInfo(const std::string& result) { m_error_info = result; }
|
||||
void SetHttpStatus(int http_status) { m_http_status = http_status; }
|
||||
void SetErrorCode(const std::string& err_code) { m_err_code = err_code; }
|
||||
void SetErrorMsg(const std::string& err_msg) { m_err_msg = err_msg; }
|
||||
void SetResourceAddr(const std::string& resource_addr) {
|
||||
m_resource_addr = resource_addr;
|
||||
}
|
||||
void SetXCosRequestId(const std::string& x_cos_request_id) {
|
||||
m_x_cos_request_id = x_cos_request_id;
|
||||
}
|
||||
void SetXCosTraceId(const std::string& x_cos_trace_id) {
|
||||
m_x_cos_trace_id = x_cos_trace_id;
|
||||
}
|
||||
|
||||
void SetRealByte(uint64_t real_byte) {
|
||||
m_real_byte = real_byte;
|
||||
}
|
||||
/// \brief 输出Result的具体信息
|
||||
std::string DebugString() const;
|
||||
|
||||
std::string GetInitMpRequestId() const {
|
||||
return m_init_mp_request_id;
|
||||
}
|
||||
void SetInitMpRequestId(const std::string& request_id) {
|
||||
m_init_mp_request_id = request_id;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_is_succ; // 标识HTTP调用是否成功
|
||||
|
||||
int m_http_status; // http状态码
|
||||
std::string m_error_info; // 错误的具体信息, 存放sdk内部错误/调用失败时无法解析的返回信息
|
||||
|
||||
// COS返回的错误信息
|
||||
std::string m_err_code;
|
||||
std::string m_err_msg;
|
||||
std::string m_resource_addr;
|
||||
std::string m_x_cos_request_id;
|
||||
std::string m_x_cos_trace_id;
|
||||
std::string m_x_cos_server_time;
|
||||
uint64_t m_real_byte;
|
||||
// MultiUploadObject接口中封装了init mp/upload part/complete,该成员保存init mp的request id
|
||||
// 如果是断点续传,则该reqeust id为空
|
||||
std::string m_init_mp_request_id;
|
||||
};
|
||||
|
||||
} // namespace qcloud_cos
|
||||
#endif // COS_RESULT_H
|
||||
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Runnable.h"
|
||||
|
||||
namespace qcloud_cos {
|
||||
|
||||
class FileCopyTask : public Poco::Runnable {
|
||||
public:
|
||||
FileCopyTask(const std::string& full_url,
|
||||
uint64_t conn_timeout_in_ms,
|
||||
uint64_t recv_timeout_in_ms);
|
||||
|
||||
~FileCopyTask() {}
|
||||
|
||||
void run();
|
||||
|
||||
void CopyTask();
|
||||
|
||||
bool IsTaskSuccess() const;
|
||||
|
||||
int GetHttpStatus() const ;
|
||||
|
||||
std::string GetTaskResp() const;
|
||||
|
||||
std::map<std::string, std::string> GetRespHeaders() const;
|
||||
|
||||
void SetParams(const std::map<std::string, std::string>& params);
|
||||
|
||||
void SetHeaders(const std::map<std::string, std::string>& headers);
|
||||
|
||||
std::string GetErrMsg() const { return m_err_msg; }
|
||||
|
||||
std::string GetEtag() const { return m_etag; }
|
||||
|
||||
std::string GetLastModified() const { return m_last_modified; }
|
||||
|
||||
private:
|
||||
std::string m_full_url;
|
||||
std::map<std::string, std::string> m_headers;
|
||||
std::map<std::string, std::string> m_params;
|
||||
uint64_t m_conn_timeout_in_ms;
|
||||
uint64_t m_recv_timeout_in_ms;
|
||||
std::string m_resp;
|
||||
bool m_is_task_success;
|
||||
int m_http_status;
|
||||
std::map<std::string, std::string> m_resp_headers;
|
||||
std::string m_err_msg;
|
||||
std::string m_etag;
|
||||
std::string m_last_modified;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright (c) 2017, Tencent Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Author: sevenyou <sevenyou@tencent.com>
|
||||
// Created: 07/25/17
|
||||
// Description:
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "trsf/transfer_handler.h"
|
||||
#include "cos_config.h"
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Runnable.h"
|
||||
|
||||
namespace qcloud_cos {
|
||||
|
||||
class FileDownTask : public Poco::Runnable {
|
||||
public:
|
||||
FileDownTask(const std::string& full_url,
|
||||
const std::map<std::string, std::string>& headers,
|
||||
const std::map<std::string, std::string>& params,
|
||||
uint64_t conn_timeout_in_ms,
|
||||
uint64_t recv_timeout_in_ms,
|
||||
const SharedTransferHandler& handler = nullptr,
|
||||
uint64_t offset = 0,
|
||||
unsigned char* pbuf = NULL,
|
||||
const size_t data_len = 0);
|
||||
|
||||
~FileDownTask() {}
|
||||
|
||||
void run();
|
||||
|
||||
void DownTask();
|
||||
|
||||
void SetDownParams(unsigned char* pdatabuf, size_t datalen, uint64_t offset);
|
||||
|
||||
std::string GetTaskResp();
|
||||
|
||||
size_t GetDownLoadLen();
|
||||
|
||||
bool IsTaskSuccess();
|
||||
|
||||
int GetHttpStatus();
|
||||
|
||||
std::map<std::string, std::string> GetRespHeaders();
|
||||
|
||||
std::string GetErrMsg() const { return m_err_msg; }
|
||||
|
||||
private:
|
||||
std::string m_full_url;
|
||||
std::map<std::string, std::string> m_headers;
|
||||
std::map<std::string, std::string> m_params;
|
||||
uint64_t m_conn_timeout_in_ms;
|
||||
uint64_t m_recv_timeout_in_ms;
|
||||
SharedTransferHandler m_handler;
|
||||
uint64_t m_offset;
|
||||
unsigned char* m_data_buf_ptr;
|
||||
size_t m_data_len;
|
||||
std::string m_resp;
|
||||
bool m_is_task_success;
|
||||
size_t m_real_down_len;
|
||||
int m_http_status;
|
||||
std::map<std::string, std::string> m_resp_headers;
|
||||
std::string m_err_msg;
|
||||
|
||||
SharedConfig m_config;
|
||||
};
|
||||
|
||||
} // namespace qcloud_cos
|
||||
@@ -0,0 +1,89 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "request/object_req.h"
|
||||
#include "trsf/transfer_handler.h"
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Runnable.h"
|
||||
|
||||
namespace qcloud_cos{
|
||||
|
||||
class FileUploadTask : public Poco::Runnable {
|
||||
public:
|
||||
FileUploadTask(const std::string& full_url,
|
||||
uint64_t conn_timeout_in_ms,
|
||||
uint64_t recv_timeout_in_ms,
|
||||
unsigned char* pbuf = NULL,
|
||||
const size_t data_len = 0);
|
||||
|
||||
FileUploadTask(const std::string& full_url,
|
||||
uint64_t conn_timeout_in_ms,
|
||||
uint64_t recv_timeout_in_ms,
|
||||
const SharedTransferHandler& handler);
|
||||
|
||||
FileUploadTask(const std::string& full_url,
|
||||
const std::map<std::string, std::string>& headers,
|
||||
const std::map<std::string, std::string>& params,
|
||||
uint64_t conn_timeout_in_ms,
|
||||
uint64_t recv_timeout_in_ms,
|
||||
unsigned char* pbuf = NULL,
|
||||
const size_t data_len = 0);
|
||||
|
||||
~FileUploadTask() {}
|
||||
|
||||
void run();
|
||||
|
||||
void UploadTask();
|
||||
|
||||
void SetUploadBuf(unsigned char* pdatabuf, size_t data_len);
|
||||
|
||||
std::string GetTaskResp() const;
|
||||
|
||||
bool IsTaskSuccess() const;
|
||||
|
||||
void SetTaskSuccess() { m_is_task_success = true; }
|
||||
|
||||
int GetHttpStatus() const ;
|
||||
|
||||
std::map<std::string, std::string> GetRespHeaders() const;
|
||||
|
||||
void SetParams(const std::map<std::string, std::string>& params);
|
||||
|
||||
void SetHeaders(const std::map<std::string, std::string>& headers);
|
||||
|
||||
std::string GetErrMsg() const { return m_err_msg; }
|
||||
|
||||
void SetResume(const bool is_resume) { m_is_resume = is_resume; }
|
||||
|
||||
bool IsResume() const { return m_is_resume; }
|
||||
|
||||
void SetResumeEtag(const std::string& etag) { m_resume_etag = etag; }
|
||||
|
||||
std::string GetResumeEtag() const { return m_resume_etag; }
|
||||
|
||||
void SetPartNumber(uint64_t part_number);
|
||||
|
||||
uint64_t GetPartNumber() const { return m_part_number;}
|
||||
|
||||
private:
|
||||
std::string m_full_url;
|
||||
std::map<std::string, std::string> m_headers;
|
||||
std::map<std::string, std::string> m_params;
|
||||
uint64_t m_conn_timeout_in_ms;
|
||||
uint64_t m_recv_timeout_in_ms;
|
||||
unsigned char* m_data_buf_ptr;
|
||||
size_t m_data_len;
|
||||
std::string m_resp;
|
||||
bool m_is_task_success;
|
||||
int m_http_status;
|
||||
std::map<std::string, std::string> m_resp_headers;
|
||||
std::string m_err_msg;
|
||||
bool m_is_resume;
|
||||
std::string m_resume_etag;
|
||||
uint64_t m_part_number;
|
||||
SharedTransferHandler m_handler;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,378 @@
|
||||
// Copyright (c) 2017, Tencent Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Author: sevenyou <sevenyou@tencent.com>
|
||||
// Created: 07/21/17
|
||||
// Description:
|
||||
|
||||
#ifndef OBJECT_OP_H
|
||||
#define OBJECT_OP_H
|
||||
#pragma once
|
||||
|
||||
#include "op/base_op.h"
|
||||
#include "op/cos_result.h"
|
||||
#include "request/object_req.h"
|
||||
#include "request/data_process_req.h"
|
||||
#include "response/object_resp.h"
|
||||
#include "response/data_process_resp.h"
|
||||
|
||||
namespace qcloud_cos {
|
||||
|
||||
class FileUploadTask;
|
||||
class FileCopyTask;
|
||||
|
||||
/// \brief 封装了Object相关的操作
|
||||
class ObjectOp : public BaseOp {
|
||||
public:
|
||||
/// \brief BucketOp构造函数
|
||||
///
|
||||
/// \param cos_conf Cos配置
|
||||
explicit ObjectOp(const SharedConfig& config) : BaseOp(config) {}
|
||||
ObjectOp() {}
|
||||
|
||||
/// \brief ObjectOP析构函数
|
||||
virtual ~ObjectOp() {}
|
||||
|
||||
/// \brief 判断object是否存在
|
||||
bool IsObjectExist(const std::string& bucket_name, const std::string& object_name);
|
||||
|
||||
std::string GetResumableUploadID(const std::string& bucket_name, const std::string& object_name) ;
|
||||
|
||||
bool CheckUploadPart(const MultiUploadObjectReq& req, const std::string& bucket_name,
|
||||
const std::string& object_name, const std::string& uploadid,
|
||||
const std::string& localpath, std::vector<std::string>& already_exist);
|
||||
|
||||
bool CheckSinglePart(const std::string& local_file_path, uint64_t offset, uint64_t local_part_size,
|
||||
uint64_t size, const std::string& etag);
|
||||
|
||||
/// \brief 获取对应Object的meta信息数据
|
||||
///
|
||||
/// \param request HeadObject请求
|
||||
/// \param response HeadObject返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult HeadObject(const HeadObjectReq& req, HeadObjectResp* resp);
|
||||
|
||||
/// \brief 下载Bucket中的一个文件至流中
|
||||
///
|
||||
/// \param request GetObjectByStream请求
|
||||
/// \param response GetObjectByStream返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult GetObject(const GetObjectByStreamReq& req, GetObjectByStreamResp* resp);
|
||||
|
||||
/// \brief 下载Bucket中的一个文件到本地
|
||||
///
|
||||
/// \param request GetObjectByFile请求
|
||||
/// \param response GetObjectByFile返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult GetObject(const GetObjectByFileReq& req, GetObjectByFileResp* resp);
|
||||
|
||||
/// \brief 多线程下载Bucket中的一个文件到本地
|
||||
///
|
||||
/// \param request MultiGetObject请求
|
||||
/// \param response MultiGetObject返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult GetObject(const MultiGetObjectReq& req, MultiGetObjectResp* resp);
|
||||
|
||||
/// \brief 将本地的文件上传至指定Bucket中
|
||||
///
|
||||
/// \param request PutObjectByFile请求
|
||||
/// \param response PutObjectByFile返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult PutObject(const PutObjectByFileReq& req, PutObjectByFileResp* resp);
|
||||
|
||||
/// \brief 将指定流上传至指定Bucket中
|
||||
///
|
||||
/// \param request PutObjectByStream请求
|
||||
/// \param response PutObjectByStream返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult PutObject(const PutObjectByStreamReq& req, PutObjectByStreamResp* resp);
|
||||
|
||||
/// \brief 删除Object
|
||||
///
|
||||
/// \param req DeleteObject请求
|
||||
/// \param resp DeleteObject返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult DeleteObject(const DeleteObjectReq& req, DeleteObjectResp* resp);
|
||||
|
||||
/// \brief 批量删除Object
|
||||
///
|
||||
/// \param req DeleteObjects请求
|
||||
/// \param resp DeleteObjects返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult DeleteObjects(const DeleteObjectsReq& req, DeleteObjectsResp* resp);
|
||||
|
||||
/// \brief 请求实现初始化分片上传,成功执行此请求以后会返回UploadId用于后续的Upload Part请求
|
||||
///
|
||||
/// \param request InitMultiUpload请求
|
||||
/// \param response InitMultiUpload返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult InitMultiUpload(const InitMultiUploadReq& req, InitMultiUploadResp* resp);
|
||||
|
||||
/// \brief 初始化以后的分块上传,支持的块的数量为1到10000,块的大小为1MB到5GB
|
||||
///
|
||||
/// \param request UploadPartData请求
|
||||
/// \param response UploadPartData返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult UploadPartData(const UploadPartDataReq& req, UploadPartDataResp* resp);
|
||||
|
||||
/// \brief 初始化以后的分块复制,实现将一个文件的分块内容从源路径复制到目标路径。
|
||||
/// 通过指定 x-cos-copy-source 来指定源文件,x-cos-copy-source-range 指定字节范围。
|
||||
/// 允许分块的大小为 5 MB - 5 GB。
|
||||
///
|
||||
/// \param request UploadPartCopyData请求
|
||||
/// \param response UploadPartCopyData返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult UploadPartCopyData(const UploadPartCopyDataReq& req, UploadPartCopyDataResp* resp);
|
||||
|
||||
/// \brief 完成整个分块上传。当使用 Upload Parts 上传完所有块以后,
|
||||
/// 必须调用该 API 来完成整个文件的分块上传
|
||||
///
|
||||
/// \param request CompleteMultiUpload请求
|
||||
/// \param response CompleteMultiUpload返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult CompleteMultiUpload(const CompleteMultiUploadReq& req, CompleteMultiUploadResp* resp);
|
||||
|
||||
/// \brief 异步多线程上传
|
||||
/// \param request MultiUploadObject请求
|
||||
/// \param response MultiUploadObject返回
|
||||
/// \param handler TransferHandler
|
||||
///
|
||||
/// \return result
|
||||
CosResult MultiUploadObject(const MultiUploadObjectReq& req, MultiUploadObjectResp* resp,
|
||||
const SharedTransferHandler& handler = nullptr);
|
||||
|
||||
/// \brief 舍弃一个分块上传并删除已上传的块
|
||||
///
|
||||
/// \param req AbortMultiUpload请求
|
||||
/// \param resp AbortMultiUpload返回
|
||||
///
|
||||
/// \return
|
||||
CosResult AbortMultiUpload(const AbortMultiUploadReq& req, AbortMultiUploadResp* resp);
|
||||
|
||||
/// \brief 查询特定分块上传中的已上传的块
|
||||
///
|
||||
/// \param req ListParts请求
|
||||
/// \param resp ListParts返回
|
||||
///
|
||||
/// \return result
|
||||
CosResult ListParts(const ListPartsReq& req, ListPartsResp* resp);
|
||||
|
||||
/// \brief 列出Object下的ACL
|
||||
///
|
||||
/// \param req GetObjectACL请求
|
||||
/// \param resp GetObjectACL返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetObjectACL(const GetObjectACLReq& req,
|
||||
GetObjectACLResp* resp);
|
||||
|
||||
/// \brief 增加/替换Object下的ACL, 可以通过Header或者Body传入ACL信息
|
||||
/// 注意Header 和 Body 只能选择其中一种,否则响应返回会冲突
|
||||
///
|
||||
/// \param req PutObjectACL请求
|
||||
/// \param resp PutObjectACL返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutObjectACL(const PutObjectACLReq& req,
|
||||
PutObjectACLResp* resp);
|
||||
|
||||
/// \brief 复制Object
|
||||
///
|
||||
/// \param req PutObjectCopy请求
|
||||
/// \param resp PutObjectCopy返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult PutObjectCopy(const PutObjectCopyReq& req,
|
||||
PutObjectCopyResp* resp);
|
||||
|
||||
/// \brief 复制文件,实现将一个文件的分块内容从源路径复制到目标路径。
|
||||
/// 通过指定 x-cos-copy-source 来指定源文件,x-cos-copy-source-range 指定字节范围。
|
||||
///
|
||||
/// \param request Copy请求
|
||||
/// \param response Copy返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult Copy(const CopyReq& req, CopyResp* resp);
|
||||
|
||||
/// \brief 对一个通过 COS 归档为 archive 类型的对象进行恢复
|
||||
///
|
||||
/// \param request PostObjectRestore请求
|
||||
/// \param response PostObjectRestore返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult PostObjectRestore(const PostObjectRestoreReq& req, PostObjectRestoreResp* resp);
|
||||
|
||||
std::string GeneratePresignedUrl(const GeneratePresignedUrlReq& req);
|
||||
|
||||
CosResult OptionsObject(const OptionsObjectReq& req, OptionsObjectResp* resp);
|
||||
|
||||
CosResult SelectObjectContent(const SelectObjectContentReq& req, SelectObjectContentResp* resp);
|
||||
|
||||
/// \brief 创建推流通道
|
||||
///
|
||||
/// \param request PutLiveChannelReq请求
|
||||
/// \param response PutLiveChannelResp返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult PutLiveChannel(const PutLiveChannelReq& req, PutLiveChannelResp* resp);
|
||||
|
||||
/// \brief 启用或禁用通道
|
||||
///
|
||||
/// \param request PutLiveChannelSwitchReq请求
|
||||
/// \param response PutLiveChannelSwitchResp返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult PutLiveChannelSwitch(const PutLiveChannelSwitchReq& req, PutLiveChannelSwitchResp* resp);
|
||||
|
||||
/// \brief 获取直播通道配置
|
||||
///
|
||||
/// \param request GetLiveChannelReq请求
|
||||
/// \param response GetLiveChannelResp返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult GetLiveChannel(const GetLiveChannelReq& req, GetLiveChannelResp* resp);
|
||||
|
||||
/// \brief 获取直播通道推流历史
|
||||
///
|
||||
/// \param request GetLiveChannelHistoryReq请求
|
||||
/// \param response GetLiveChannelHistoryResp返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult GetLiveChannelHistory(const GetLiveChannelHistoryReq& req, GetLiveChannelHistoryResp* resp);
|
||||
|
||||
/// \brief 获取直播通道推流状态
|
||||
///
|
||||
/// \param request GetLiveChannelStatusReq请求
|
||||
/// \param response GetLiveChannelStatusResp返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult GetLiveChannelStatus(const GetLiveChannelStatusReq& req, GetLiveChannelStatusResp* resp);
|
||||
|
||||
/// \brief 删除直播通
|
||||
///
|
||||
/// \param request DeleteLiveChannelReq请求
|
||||
/// \param response DeleteLiveChannelResp返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult DeleteLiveChannel(const DeleteLiveChannelReq& req, DeleteLiveChannelResp* resp);
|
||||
|
||||
/// \brief 查询指定通道在指定时间段推流生成的播放列表
|
||||
///
|
||||
/// \param request GetLiveChannelVodPlaylistReq请求
|
||||
/// \param response GetLiveChannelVodPlaylistResp返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult GetLiveChannelVodPlaylist(const GetLiveChannelVodPlaylistReq& req, GetLiveChannelVodPlaylistResp* resp);
|
||||
|
||||
/// \brief 指定通道生成一个可供点播例用的播放列表
|
||||
///
|
||||
/// \param request PostLiveChannelVodPlaylistReq请求
|
||||
/// \param response GetLiveChannelVodPlaylistResp返回
|
||||
///
|
||||
/// \return 返回HTTP请求的状态码及错误信息
|
||||
CosResult PostLiveChannelVodPlaylist(const PostLiveChannelVodPlaylistReq& req,
|
||||
PostLiveChannelVodPlaylistResp* resp);
|
||||
|
||||
/// \brief 异步多线程下载,handler处理回调
|
||||
CosResult MultiThreadDownload(const MultiGetObjectReq& req, MultiGetObjectResp* resp,
|
||||
const SharedTransferHandler& handler = nullptr);
|
||||
|
||||
/*Resumable接口*/
|
||||
|
||||
/// \brief 支持断点下载
|
||||
CosResult ResumableGetObject(const MultiGetObjectReq& req, MultiGetObjectResp* resp);
|
||||
|
||||
/*批量及目录操作接口*/
|
||||
CosResult PutObjects(const PutObjectsByDirectoryReq& req, PutObjectsByDirectoryResp* resp);
|
||||
|
||||
CosResult PutDirectory(const PutDirectoryReq& req, PutDirectoryResp* resp);
|
||||
|
||||
CosResult MoveObject(const MoveObjectReq& req, MoveObjectResp* resp);
|
||||
|
||||
|
||||
/*数据处理接口*/
|
||||
|
||||
/**基础图片处理**/
|
||||
|
||||
/**图片持久化处理**/
|
||||
|
||||
/***上传时处理***/
|
||||
CosResult PutImage(const PutImageByFileReq& req, PutImageByFileResp* resp);
|
||||
|
||||
/***云上数据处理***/
|
||||
CosResult CloudImageProcess(const CloudImageProcessReq& req, CloudImageProcessResp* resp);
|
||||
|
||||
/***下载图片时识别二维码***/
|
||||
CosResult GetQRcode(const GetQRcodeReq& req, GetQRcodeResp* resp);
|
||||
|
||||
/*文档处理接口*/
|
||||
|
||||
/**查询已经开通文档预览功能的 Bucket**/
|
||||
|
||||
CosResult DescribeDocProcessBuckets(const DescribeDocProcessBucketsReq& req, DescribeDocProcessBucketsResp *resp);
|
||||
|
||||
/**预览文档**/
|
||||
CosResult DocPreview(const DocPreviewReq& req, DocPreviewResp *resp);
|
||||
|
||||
private:
|
||||
// 生成request body所需的xml字符串
|
||||
bool GenerateCompleteMultiUploadReqBody(const CompleteMultiUploadReq& req,
|
||||
std::string* req_body);
|
||||
|
||||
/// \brief 多线程上传,handler处理回调
|
||||
CosResult MultiThreadUpload(const MultiUploadObjectReq& req,
|
||||
const std::string& upload_id,
|
||||
const std::vector<std::string>& already_exist_parts,
|
||||
bool resume_flag,
|
||||
std::vector<std::string>* etags_ptr,
|
||||
std::vector<uint64_t>* part_numbers_ptr,
|
||||
const SharedTransferHandler& handler = nullptr);
|
||||
|
||||
/// \brief 读取文件内容, 并返回读取的长度
|
||||
uint64_t GetContent(const std::string& src, std::string* file_content) const;
|
||||
|
||||
void FillUploadTask(const std::string& upload_id, const std::string& host,
|
||||
const std::string& path, unsigned char* file_content_buf,
|
||||
uint64_t len, uint64_t part_number,
|
||||
FileUploadTask* task_ptr);
|
||||
|
||||
void FillCopyTask(const std::string& upload_id, const std::string& host,
|
||||
const std::string& path, uint64_t part_number,
|
||||
const std::string& range,
|
||||
const std::map<std::string, std::string>& headers,
|
||||
const std::map<std::string, std::string>& params,
|
||||
FileCopyTask* task);
|
||||
|
||||
/// \brief 检查是否可以走断点下载
|
||||
/// \param req MultiUploadObjectReq请求
|
||||
/// \param head_resp HeadObjectResp响应结果
|
||||
/// \param last_offset 返回的上一次下载偏移量
|
||||
/// \return true可以走断点下载,false表示不可以
|
||||
bool CheckResumableDownloadTask(const std::string& json_file,
|
||||
const std::map<std::string, std::string>& element_map,
|
||||
uint64_t *resume_offset);
|
||||
/// \brief 更新断点下载json文件
|
||||
/// \param json_file json文件名
|
||||
/// \param element_map 检查的元素映射
|
||||
/// \param last_offset 返回的上一次下载偏移量
|
||||
/// \return true文件检查成功, 否则失败
|
||||
void UpdateResumableDownloadTaskFile(const std::string& json_file,
|
||||
const std::map<std::string, std::string>& element_map,
|
||||
uint64_t resume_offset);
|
||||
|
||||
};
|
||||
|
||||
} // namespace qcloud_cos
|
||||
#endif // OBJECT_OP_H
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2017, Tencent Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Author: sevenyou <sevenyou@tencent.com>
|
||||
// Created: 11/14/17
|
||||
// Description:
|
||||
|
||||
#ifndef SERVICEOP_H
|
||||
#define SERVICEOP_H
|
||||
#pragma once
|
||||
|
||||
#include "cos_sys_config.h"
|
||||
#include "op/base_op.h"
|
||||
#include "op/cos_result.h"
|
||||
#include "request/service_req.h"
|
||||
#include "response/service_resp.h"
|
||||
|
||||
namespace qcloud_cos {
|
||||
|
||||
/// \brief 封装了Service相关的操作
|
||||
class ServiceOp : public BaseOp {
|
||||
public:
|
||||
/// \brief ServiceOp构造函数
|
||||
///
|
||||
/// \param cos_conf Cos配置
|
||||
explicit ServiceOp(const SharedConfig& config) : BaseOp(config) {}
|
||||
|
||||
/// \brief ServiceOp析构函数
|
||||
virtual ~ServiceOp() {}
|
||||
|
||||
/// \brief 获取请求者名下的所有存储空间列表Bucket list
|
||||
/// (详见:https://cloud.tencent.com/document/api/436/8291)
|
||||
///
|
||||
/// \param req GetService请求
|
||||
/// \param resp GetService返回
|
||||
///
|
||||
/// \return 本次请求的调用情况(如状态码等)
|
||||
CosResult GetService(const GetServiceReq& req, GetServiceResp* resp);
|
||||
};
|
||||
|
||||
} // namespace qcloud_cos
|
||||
#endif // SERVICEOP_H
|
||||
Reference in New Issue
Block a user