tencent cloud

Video on Demand

動向とお知らせ
製品アップデート情報
製品紹介
製品概要
Product Features
製品の機能
製品の強み
ユースケース
ソリューション
購入ガイド
課金概要
課金方式
購入ガイドライン
請求書の照会
支払い更新の説明
支払い延滞の説明
返金説明
クイックスタート
コンソールガイド
コンソールの説明
サービスの概要
アプリケーション管理
メディア管理
リソースパック管理
License Management
プラクティスチュートリアル
メディアのアップロード
オンデマンドメディアファイルのインテリジェントコールド化方法
ビデオ処理
配信と再生
イベント通知の受信方法
オリジンサーバーのマイグレーションツール
Live Recording
カスタムオリジンサーバーback-to-originの方法
ライブストリーミングハイライトクリップを VOD に永続化するためのガイド
EdgeOne を使用して VOD コンテンツを配信する方法
開発ガイド
メディアアップロード
メディア加工処理
ビデオAI
イベント通知
ビデオ再生
メディアファイルのダウンロード
サブアプリケーションシステム
エラーコード
Player+ドキュメント
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
よくあるご質問
モバイル端末再生に関するご質問
料金
ビデオのアップロード
ビデオの公開
ビデオの再生
Web側の再生
全画面表示再生
データ統計
CAM関連
メディア資産冷却に関する質問
Agreements
Service Level Agreement
VOD ポリシー
プライバシーポリシー
データ処理とセキュリティ契約
お問い合わせ
用語集
ドキュメントVideo on Demand

Flutter Upload SDK

フォーカスモード
フォントサイズ
最終更新日: 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.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック