tencent cloud

Video on Demand

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Product Features
Features
Strengths
Scenarios
Solutions
Professional Edition
Introduction to Video On Demand Professional Edition
Quick Start
Console Guide
Development Guide
Purchase Guide
Billing Overview
Billing Modes
Purchase Guide
Viewing Bills
Renewal
Overdue Policy
Refund Policy
Getting Started
Console Guide
Console Overview
Service Overview
Application Management
Media Management
Package Management
License Management
Real-Time Log Analysis
Practical Tutorial
Media Upload
Smart Cold Storage of VOD Media Asset Files
Video Processing
Distribution and Playback
How to Receive Event Notification
How to Migrate Files from Origin Server to VOD
Live Recording
How to Pull from Custom Origin Servers
How to Use EdgeOne to Distribute Content in VOD
Development Guide
Media Upload
Media Processing
Video AI
Event Notification
Video Playback
Media Encryption and Copyright Protection
Broadcast Channel
CAM
Media File Download
Subapplication System
Error Codes
Player SDK
Overview
Basic Concepts
Features
Free Demo
Free Trial License
Purchase Guide
SDK Download
Licenses
Player Guide
Integration (UI Included)
Integration (No UI)
Advanced Features
API Documentation
Player Adapter
Player SDK Policy
Server APIs
History
Introduction
API Category
Other APIs
Media Processing APIs
Task Management APIs
Media Upload APIs
Media Management APIs
Event Notification Relevant API
Media Categorization APIs
Domain Name Management APIs
Distribution APIs
AI-based Sample Management APIs
Region Management APIs
Data Statistics APIs
Carousel-Related APIs
Just In Time Transcode APIs
No longer recommended APIs
Making API Requests
AI-based image processing APIs
Parameter Template APIs
Task Flow APIs
Data Types
Error Codes
Video on Demand API 2024-07-18
FAQs
Mobile Playback
Fees
Video Upload
Video Publishing
Video Playback
Web Playback
Full Screen Playback
Statistics
Access Management
Cold Storage
Agreements
Service Level Agreement
VOD Policy
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Flutter Upload SDK

PDF
Focus Mode
Font Size
Last updated: 2025-08-05 09:38:22
This example is based on VOD Professional Flutter SDK v1.0.2.

​Environment Preparation​

Flutter SDK Version: ≥ 3.3.0.
When uploading media files on iOS and Android, if media files uploaded by your app are sourced from the gallery or device storage, you must configure and request necessary permissions (e.g., gallery access, storage access).
​The demo uses third-party plugins for access and configures required permissions. Adjust according to your business scenario.​​
<uses-permission android:name="android.permission.INTERNET"/>

Dependencies​

Copy the voduploadadv project locally and use a relative path for dependency.
​Example​ (assuming voduploadadv is in a sibling directory):
voduploadadv:
path: ../voduploadadv/
After adding, run these commands to refresh dependencies:
flutter clean
flutter pub get

Authentication Configuration​

Upload requires client identity authentication. Configure an authentication callback to provide secretId, secretKey, token, and expiredTime when needed by the SDK.
Note:
This configuration is mandatory. Skipping it will cause upload failures.​​
TxVodUploadPlugin.instance.initWithScopeLimitCredential((stsCredentialScopes) async {
// Recommended: Fetch credentials from your server
Map<String, dynamic> jsonMap = jsonDecode(testRsCre);
Map<String, dynamic> resJsonMap = jsonMap["Response"];
Map<String, dynamic> credentialsJsonMap = resJsonMap["Credentials"];
int expiredTimeStamp = DateTime.parse(credentialsJsonMap['Expiration']).millisecondsSinceEpoch;
return FTXSessionQCloudCredentials(
secretId: credentialsJsonMap["AccessKeyId"],
secretKey: credentialsJsonMap["SecretAccessKey"],
token: credentialsJsonMap["SessionToken"],
expiredTime: expiredTimeStamp);
});
The stsCredentialScopes parameter includes:
region: Default empty string.
bucket: Your bucket ID (auto in auto-mode).
prefix: Directory prefix (default empty).
action: Possible values:
// Simple upload
"name/cos:PutObject",
// Form upload
"name/cos:PostObject",
// Multipart upload: Initiate
"name/cos:InitiateMultipartUpload",
// Multipart upload: List ongoing
"name/cos:ListMultipartUploads",
// Multipart upload: List uploaded parts
"name/cos:ListParts",
// Multipart upload: Upload part
"name/cos:UploadPart",
// Multipart upload: Complete
"name/cos:CompleteMultipartUpload",
// Multipart upload: Abort
"name/cos:AbortMultipartUpload"
Use these fields to distinguish credentials for different upload operations.

Create Uploader Object​

When creating a TXUploader, there are two modes: subApp and bucket, corresponding to the automatic mode and the specified bucket mode respectively.
The two modes correspond to the construction methods TXUploader.bucketMode and TXUploader.autoMode respectively. In addition, you also need to pass in your sub-application ID. The sample code is as follows:
_uploader = TXUploader.bucketMode(0000000000, "xxxxxxxxxxxxx");

Set Upload Callbacks​

After creation, if you need to monitor the upload status, you need to set up callbacks. All callbacks are optional for implementation, and the business can implement them according to its own needs. The sample code for setting up callbacks is as follows:
_uploader?.setUploadCallback = FTXUploadCallback(
successCallBack: (header, result) async {
// Upload success! Access file URL via result.accessUrl
},
failCallBack: (clientException, serviceException) async {
// Handle upload failure
},
progressCallBack: (complete, target) {
// Progress: 'complete' = bytes uploaded, 'target' = total bytes
},
stateCallBack:(state) {
// State change notification
},
startUploadCallback: (bucket, cosKey, uploadId) async {
// Upload started! Store 'uploadId' for resuming later
}
);

Start Uploading​

​Optional:​​ Configure upload settings before starting:
UploadConfig uploadConfig = UploadConfig();
uploadConfig.sliceSizeForUpload = 1024 * 1024 * 2; // Default: 2MB slice size (adjustable)
uploadConfig.isHttps = true; // Use HTTPS (default: true)
uploadConfig.enableVerification = true; // Enable slice verification (default: true)

Configure Upload Parameters​

UploadParams properties:
Parameter
Description
localFilePath
Local file path (required).
fileKey
Filename on server (required).
uploadId
Resume upload using previous ID (optional).
uploadConfig
Upload settings (optional).
​Start upload:​​
int? code = await _uploader?.upload(params);
if (code == TXUploadCode.TX_UPLOAD_OK) {
showResult("Upload started");
} else {
showResult("Upload failed with code $code");
}
Return Codes:​​
TXUploadCode.TX_UPLOAD_OK: Success.
TXUploadCode.TX_UPLOAD_BUSY: Uploader busy.
TX_FILE_NOT_FOUND: Invalid file path.

Help and Support

Was this page helpful?

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

Feedback