tencent cloud

Smart Media Hosting

Product Introduction
Product Overview
Feature Description
Product Strengths
Use Cases
Basic Concept
Purchase Guide
Quick Start
Create Media Library
Initiate request
Service Level API Document
History
Introduction
API Category
Making API Requests
PaaS Service APIs
Official Cloud Disk APIs
Data Types
Error Codes
Business Level API Document
Introduction
Access Token Operation API
Tenant Space Operation API
File Operation API
Directory or Album Operation API
Recycle Bin Operation API
Quota Operation API
Query Task Operation API
Search Operation API
Historical Version Operations API
Directory and File Batch Operation API
Collection Operation API
Error Codes
SDK Documentation
Android SDK
iOS SDK
HarmonyOS SDK
FAQs
Enterprise Network Disk
Product Introduction
Purchase Guide
Quick Start
FAQs
Service Level Agreement
Glossary

Uploading

PDF
Focus Mode
Font Size
Last updated: 2026-01-07 10:49:05

Introduction

This document provides an API overview for file upload as well as SDK example code.

SDK API Reference

For specific parameters and method descriptions of all SDK APIs, refer to SDK API Reference.

Advanced Upload

Feature Description

The upload method automatically performs fast upload, simple upload, and multipart upload logic.

Starting Upload or Resuming Upload

QCloudCOSSMHUploadObjectRequest *uploadReq = [QCloudCOSSMHUploadObjectRequest new];
// If confirmKey is set, deem as resume upload; otherwise, it's a new upload task.
// Get from the getConfirmKey callback.
uploadReq.confirmKey = @"confirmKey";
// Set the libraryId where the directory to be uploaded is located.
uploadReq.libraryId = @"libraryId";
// Set the libraryId where the directory to be uploaded is located.
uploadReq.spaceId = @"spaceId";
// URL or data of the uploaded file
uploadReq.body = @"uploadBody";
uploadReq.uploadPath = @"target path";
// confirmKey callback
uploadReq.getConfirmKey = ^(NSString *_Nullable confirmKey) {
// confirmKey is required for resuming uploads, business needs to save
};
// upload progress callback
[uploadReq setSendProcessBlock:^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {

}];
// upload result callback
[uploadReq setFinishBlock:^(QCloudSMHContentInfo *result, NSError *error) {

}];
// Start uploading
[[QCloudSMHService defaultSMHService] uploadObject:uploadReq];

Pause

Execute the cancel method on the request created during upload.
[uploadReq cancel];

Cancel Upload

Execute the abort method on the request created during upload. You can do some cleanup in the completion callback.
[uploadReq abort:^(id outputObject, NSError *error) {
// end callback
}];
Note:
To implement resuming upload after an App is killed and reopened, the business-side needs to persist the confirmkey as well as the corresponding body, libraryId, spaceId, and uploadPath of this upload task, then recreate the request and start uploading when entering the App again.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback