Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/op/object_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class ObjectOp : public BaseOp {
bool IsObjectExist(const std::string& bucket_name,
const std::string& object_name);

std::string GetResumableUploadID(const std::string& bucket_name,
std::string GetResumableUploadID(const PutObjectByFileReq& originReq,
const std::string& bucket_name,
const std::string& object_name);

bool CheckUploadPart(const PutObjectByFileReq& req,
Expand Down
21 changes: 19 additions & 2 deletions src/op/object_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@ bool ObjectOp::IsObjectExist(const std::string& bucket_name,
return false;
}

std::string ObjectOp::GetResumableUploadID(const std::string& bucket_name,
std::string ObjectOp::GetResumableUploadID(const PutObjectByFileReq& originReq,
const std::string& bucket_name,
const std::string& object_name) {
ListMultipartUploadReq req(bucket_name);
req.SetPrefix(object_name);
if (originReq.IsHttps()) {
req.SetHttps();
req.SetCaLocation(originReq.GetCaLocation());
}
ListMultipartUploadResp resp;

std::string host = CosSysConfig::GetHost(GetAppId(), m_config->GetRegion(),
Expand Down Expand Up @@ -184,6 +189,10 @@ bool ObjectOp::CheckUploadPart(const PutObjectByFileReq& req,

while (!list_over_flag) {
std::string marker = StringUtil::IntToString(part_num_marker);
if(req.IsHttps()){
list_req.SetHttps();
list_req.SetCaLocation(req.GetCaLocation());
}
list_req.SetPartNumberMarker(marker);
CosResult result = ListParts(list_req, &resp);
// Add to the parts_info;
Expand Down Expand Up @@ -553,7 +562,7 @@ CosResult ObjectOp::MultiUploadObject(const PutObjectByFileReq& req,
bool resume_flag = false;
std::vector<std::string> already_exist_parts(kMaxPartNumbers);
// check the breakpoint
std::string resume_uploadid = GetResumableUploadID(bucket_name, object_name);
std::string resume_uploadid = GetResumableUploadID(req ,bucket_name, object_name);
if (!resume_uploadid.empty()) {
resume_flag = CheckUploadPart(req, bucket_name, object_name,
resume_uploadid, already_exist_parts);
Expand Down Expand Up @@ -590,6 +599,10 @@ CosResult ObjectOp::MultiUploadObject(const PutObjectByFileReq& req,

CosResult init_result;
InitMultiUploadResp init_resp;
if (req.IsHttps()) {
init_req.SetHttps();
init_req.SetCaLocation(req.GetCaLocation());
}
init_req.AddHeaders(req.GetHeaders());
init_req.SetConnTimeoutInms(req.GetConnTimeoutInms());
init_req.SetRecvTimeoutInms(req.GetRecvTimeoutInms());
Expand Down Expand Up @@ -666,6 +679,10 @@ CosResult ObjectOp::MultiUploadObject(const PutObjectByFileReq& req,
comp_req.SetRecvTimeoutInms(req.GetRecvTimeoutInms() * 2);
comp_req.SetEtags(etags);
comp_req.SetPartNumbers(part_numbers);
if (req.IsHttps()) {
comp_req.SetHttps();
comp_req.SetCaLocation(req.GetCaLocation());
}

comp_result = CompleteMultiUpload(comp_req, &comp_resp);
// check crc64 if needed
Expand Down