tencent cloud

Video on Demand

릴리스 노트 및 공지 사항
릴리스 노트
제품 소개
제품 개요
Product Features
제품 기능
제품 장점
시나리오
솔루션
구매 가이드
과금 개요
과금 방식
구매 가이드
청구서 조회
연장 안내
연체 안내
환불 안내
시작하기
콘솔 가이드
콘솔 소개
서비스 개요
애플리케이션 관리
미디어 관리
리소스 패키지 관리
License Management
사례 튜토리얼
미디어 업로드
VOD 미디어 파일을 스마트 콜드 스토리지하는 방법
비디오 처리
배포 및 재생
이벤트 알림 수신 방법
원본 서버 마이그레이션 방법
라이브 방송 녹화
사용자 지정 Origin-pull을 수행하는 방법
라이브 방송 하이라이트 클리핑을 VOD에 통합하기 위한 가이드
EdgeOne을 사용하여 VOD 콘텐츠 배포하는 방법
개발 가이드
미디어 업로드
미디어 처리
비디오 AI
이벤트 알림
비디오 재생
미디어 파일 다운로드
서브 애플리케이션 시스템
오류 코드
플레이어 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
FAQs
모바일 재생
요금
비디오 업로드
비디오 배포
비디오 재생
Web 재생
전체 화면 재생
데이터 통계
액세스 관리
미디어 자산 콜드 스토리지
Agreements
Service Level Agreement
VOD 정책
개인 정보 보호 정책
데이터 처리 및 보안 계약
문의하기
용어집
문서Video on Demand

Client-side Upload​ Guide

포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-08-05 09:48:07
This document provides client-side upload guidance for Professional Edition applications.

Applicable Scenarios

End users upload local videos from clients to Tencent Cloud VOD, suitable for UGC, PGC, and similar scenarios.

Upload Methods

Since clients have high security requirements for keys, we recommend using credentials via Professional Edition preset domains. Supported methods are as follows:
Upload Method
Domain
Credentials
Supported Operations
Bucket Preset Domain
[BucketId].vodpro.[StorageRegion].eovod.com
Credentials
Upload to specified bucket
Application Preset Domain
[SubAppId].vodpro-upload.com
Credentials
Upload to specified bucket
Nearby upload to bucket in application region

Uploading Files Using Credentials

Temporary credentials are typically used in scenarios requiring high key security. The overall process is as follows:
Client Uploading Files to Professional Edition Storage Using Temporary Credentials
Client Uploading Files to Professional Edition Storage Using Temporary Credentials

1. Apply for upload credentials.
1.1 Client requests upload credentials from App backend.
1.2 Server calls Professional Edition service's API: CreateStorageCredentials
2. Client uses credentials to upload files to Tencent Cloud VOD Professional Edition storage

Preparation

1. Create the Professional Edition application and bucket in the VOD Console. For specific steps, refer to Quick Start and Create Bucket.
2. Obtain Tencent Cloud account AccessKey pair:
2.1 Log in to Tencent Cloud Console, select Cloud Access Management > Access Key > API Keys, enter the "API Key Management" page.
2.2 Obtain Cloud API key. If you haven't created a key, click New Key to create a pair of SecretId and SecretKey.

Server Applying for Upload Credentials

The VOD Pro server uses SecretId and SecretKey to call the Create Storage Credentials interface, obtains upload credentials, and distributes them to clients.
Assume Professional Edition application ID is 1234567890, bucket region is ap-guangzhou, and bucket ID is bucketid1.
Server applies for credentials to upload upload/demo.mp4 to bucketid1 bucket:
GO
Java
C++
Python
// Package main
package main

import (
"context"
"encoding/json"
"fmt"
"log"
"net/url"

"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
vod20240718 "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/vod/v20240718"
)

const (
appId = 251000000 // Tencent Cloud account APPID
subAppId = 1234567890 // VOD Professional Edition application APPID
bucketId = "bucketid1" // VOD Professional Edition bucket ID
fileKey = "upload/demo.mp4" // File KEY in storage after upload
)

// createStorageCredentialsPolicy Storage credential policy
type createStorageCredentialsPolicy struct {
Statement []policyStatement `json:"statement"`
Version string `json:"version"`
}

// policyStatement Policy statement
type policyStatement struct {
Action []string `json:"action"`
Effect string `json:"effect"`
Resource []string `json:"resource"`
}

// cred Temporary credentials
type cred struct {
AccessKeyId string
SecretAccessKey string
SessionToken string
}

// getCredential Obtain credentials
func getCredential(context.Context) (*cred, error) {
// 1. Obtain credentials
// 1.1 Initialize Tencent Cloud API object
credential := common.NewCredential(
"SecretId", // Tencent Cloud account SecretId
"SecretKey", // Tencent Cloud account SecretKey
)
prof := profile.NewClientProfile()
vodClient, err := vod20240718.NewClient(credential, "ap-guangzhou", prof)
if err != nil {
log.Fatalf("Failed to create VOD client: %+v", err)
return nil, fmt.Errorf("Failed to create VOD client: %w", err)
}

// 1.2 Construct temporary credential request
policy := createStorageCredentialsPolicy{
Statement: []policyStatement{{
Action: []string{ // Currently supported actions
"name/vod:PutObject",
"name/vod:ListParts",
"name/vod:PostObject",
"name/vod:CreateMultipartUpload",
"name/vod:UploadPart",
"name/vod:CompleteMultipartUpload",
"name/vod:AbortMultipartUpload",
"name/vod:ListMultipartUploads",
},
Effect: "allow",
Resource: []string{
fmt.Sprintf("qcs::vod:%s:uid/%d:prefix//%d/%s/%s",
"ap-guangzhou", // Bucket region
appId, // Tencent Cloud account APPID
subAppId, // VOD Professional Edition application APPID
bucketId, // VOD Professional Edition bucket ID
fileKey, // File KEY in storage after upload
),
},
}},
Version: "2.0",
}
req := vod20240718.NewCreateStorageCredentialsRequest()
req.SubAppId = common.Uint64Ptr(subAppId)
policyStr, _ := json.Marshal(policy)
req.Policy = common.StringPtr(url.QueryEscape(string(policyStr)))

// 1.3 Apply for upload credentials
resp, err := vodClient.CreateStorageCredentials(req)
if err != nil {
log.Fatalf("Failed to create storage credentials: %+v", err)
return nil, fmt.Errorf("Failed to create storage credentials: %w", err)
}
log.Printf("Successfully created storage credentials: %+v", resp)
creds := resp.Response.Credentials
return &cred{
AccessKeyId: *creds.AccessKeyId,
SecretAccessKey: *creds.SecretAccessKey,
SessionToken: *creds.SessionToken,
}, nil
}
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.vod.v20240718.VodClient;
import com.tencentcloudapi.vod.v20240718.models.CreateStorageCredentialsRequest;
import com.tencentcloudapi.vod.v20240718.models.CreateStorageCredentialsResponse;

import org.json.JSONArray;
import org.json.JSONObject;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

/**
* Credential helper class for obtaining temporary storage credentials
*/
public class CredentialHelper {
// Constant definitions
private static final long APP_ID = 251000000; // Tencent Cloud account APPID
private static final long SUB_APP_ID = 1234567890; // VOD Professional Edition application APPID
private static final String BUCKET_ID = "bucketid1"; // VOD Professional Edition bucket ID
private static final String FILE_KEY = "upload/demo.mp4"; // File KEY in storage after upload
private static final String REGION = "ap-guangzhou"; // Bucket region

/**
* Credential object storing temporary credential information
*/
public static class Cred {
private final String accessKeyId;
private final String secretAccessKey;
private final String sessionToken;

public Cred(String accessKeyId, String secretAccessKey, String sessionToken) {
this.accessKeyId = accessKeyId;
this.secretAccessKey = secretAccessKey;
this.sessionToken = sessionToken;
}

public String getAccessKeyId() {
return accessKeyId;
}

public String getSecretAccessKey() {
return secretAccessKey;
}

public String getSessionToken() {
return sessionToken;
}
}

/**
* Obtain credentials
*
* @return Temporary credential object
* @throws Exception If credential acquisition fails
*/
public static Cred getCredential() throws Exception {
try {
// 1. Initialize Tencent Cloud API client
Credential credential = new Credential("SecretId", "SecretKey"); // Tencent Cloud account SecretId and SecretKey
ClientProfile clientProfile = new ClientProfile(); // Client configuration
VodClient vodClient = new VodClient(credential, "ap-guangzhou", clientProfile); // Create VodClient object

// 2. Construct and encode policy
String policyJson = createPolicyJson();
String encodedPolicy = URLEncoder.encode(policyJson, StandardCharsets.UTF_8.name());

// 3. Create and send request
CreateStorageCredentialsRequest req = new CreateStorageCredentialsRequest();
req.setSubAppId(SUB_APP_ID); // VOD Professional Edition application APPID
req.setPolicy(encodedPolicy); // Policy

// 4. Get response and return credentials
CreateStorageCredentialsResponse resp = vodClient.CreateStorageCredentials(req);

return new Cred(
resp.getCredentials().getAccessKeyId(),
resp.getCredentials().getSecretAccessKey(),
resp.getCredentials().getSessionToken());
} catch (TencentCloudSDKException e) {
System.err.println("Failed to obtain storage credentials: " + e.getMessage());
throw new Exception("Failed to obtain storage credentials", e);
}
}

/**
* Create policy JSON string using org.json library
*
* @return Policy JSON string
*/
private static String createPolicyJson() {
// Build resource path
String resource = String.format(
"qcs::vod:%s:uid/%d:prefix//%d/%s/%s",
REGION,
APP_ID,
SUB_APP_ID,
BUCKET_ID,
FILE_KEY);

// Build operation list
String[] actions = {
"name/vod:PutObject",
"name/vod:ListParts",
"name/vod:PostObject",
"name/vod:CreateMultipartUpload",
"name/vod:UploadPart",
"name/vod:CompleteMultipartUpload",
"name/vod:AbortMultipartUpload",
"name/vod:ListMultipartUploads"
};

// Build JSON using JSONObject
JSONObject policy = new JSONObject();
policy.put("version", "2.0");

JSONArray statements = new JSONArray();
JSONObject statement = new JSONObject();

JSONArray actionArray = new JSONArray();
for (String action : actions) {
actionArray.put(action);
}
statement.put("action", actionArray);

statement.put("effect", "allow");

JSONArray resources = new JSONArray();
resources.put(resource);
statement.put("resource", resources);

statements.put(statement);
policy.put("statement", statements);

return policy.toString();
}
}
#include <tencentcloud/core/TencentCloud.h>
#include <tencentcloud/core/profile/ClientProfile.h>
#include <tencentcloud/core/profile/HttpProfile.h>
#include <tencentcloud/core/Credential.h>
#include <tencentcloud/vod/v20240718/VodClient.h>
#include <tencentcloud/vod/v20240718/model/CreateStorageCredentialsRequest.h>
#include <tencentcloud/vod/v20240718/model/CreateStorageCredentialsResponse.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <nlohmann/json.hpp>

using json = nlohmann::json;

const uint64_t APP_ID = 251000000; // Tencent Cloud account APPID
const uint64_t SUB_APP_ID = 1234567890; // VOD Professional Edition application APPID
const std::string BUCKET_ID = "bucketid1"; // VOD Professional Edition bucket ID
const std::string REGION = "ap-guangzhou"; // VOD Professional Edition bucket region
const std::string OBJECT_KEY = "upload/demo.mp4"; // File KEY to apply permissions for

// Credential struct
struct Credential
{
std::string accessKeyId;
std::string secretAccessKey;
std::string sessionToken;
};

// URL encoding function
std::string UrlEncode(const std::string &value)
{
std::ostringstream escaped;
escaped.fill('0');
escaped << std::hex;

for (char c : value)
{
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~')
{
escaped << c;
}
else
{
escaped << std::uppercase;
escaped << '%' << std::setw(2) << int((unsigned char)c);
escaped << std::nouppercase;
}
}

return escaped.str();
}

// Obtain credentials
Credential GetCredential()
{
// Initialize Tencent Cloud SDK
TencentCloud::InitAPI();

// Create VOD client
TencentCloud::Credential credential("SecretId", "SecretKey"); // Fill in Tencent Cloud account SecretId and SecretKey
TencentCloud::HttpProfile httpProfile;
TencentCloud::ClientProfile clientProfile;
clientProfile.SetHttpProfile(httpProfile);

TencentCloud::Vod::V20240718::VodClient client(credential, "ap-guangzhou", clientProfile);

// Build policy
json policy_json = {
{"statement", {{{"action", {"name/vod:PutObject", "name/vod:ListParts", "name/vod:PostObject", "name/vod:CreateMultipartUpload", "name/vod:UploadPart", "name/vod:CompleteMultipartUpload", "name/vod:AbortMultipartUpload", "name/vod:ListMultipartUploads"}}, {"effect", "allow"}, {"resource", {"qcs::vod:" + REGION + ":uid/" + std::to_string(APP_ID) + ":prefix//" + std::to_string(SUB_APP_ID) + "/" + BUCKET_ID + "/" + OBJECT_KEY}}}}},
{"version", "2.0"}};
std::string policy = policy_json.dump();

// Create request object
TencentCloud::Vod::V20240718::Model::CreateStorageCredentialsRequest req;
req.SetSubAppId(SUB_APP_ID);
req.SetPolicy(UrlEncode(policy));

// Send request
auto outcome = client.CreateStorageCredentials(req);
if (!outcome.IsSuccess())
{
std::cerr << "Failed to get storage credentials: " << outcome.GetError().GetErrorMessage() << std::endl;
TencentCloud::ShutdownAPI();
exit(1);
}

// Extract credentials
auto response = outcome.GetResult();
auto creds = response.GetCredentials();

Credential result;
result.accessKeyId = creds.GetAccessKeyId();
result.secretAccessKey = creds.GetSecretAccessKey();
result.sessionToken = creds.GetSessionToken();

// Clean up Tencent Cloud SDK
TencentCloud::ShutdownAPI();

return result;
}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
import urllib.parse
from typing import NamedTuple

from tencentcloud.common import credential
from tencentcloud.common.profile import client_profile
from tencentcloud.vod.v20240718 import vod_client, models

# Constant definitions
APP_ID = 251000000 # Tencent Cloud account APPID
SUB_APP_ID = 1234567890 # VOD Professional Edition application APPID
BUCKET_ID = "bucketid1" # VOD Professional Edition bucket ID
OBJECT_KEY = "upload/demo.mp4" # File KEY in storage after upload
REGION = "ap-guangzhou" # Region


class Credential(NamedTuple):
"""Temporary credentials"""
access_key_id: str
secret_access_key: str
session_token: str


def get_credential() -> Credential:
"""Obtain credentials"""
# 1. Initialize Tencent Cloud API object
cred = credential.Credential(
"SecretId", # Tencent Cloud account SecretId
"SecretKey", # Tencent Cloud account SecretKey
)
prof = client_profile.ClientProfile()
vod_cli = vod_client.VodClient(cred, "ap-guangzhou", prof)

# 2. Construct upload temporary credential request
policy = {
"statement": [
{
"action": [
"name/vod:PutObject",
"name/vod:ListParts",
"name/vod:PostObject",
"name/vod:CreateMultipartUpload",
"name/vod:UploadPart",
"name/vod:CompleteMultipartUpload",
"name/vod:AbortMultipartUpload",
"name/vod:ListMultipartUploads",
],
"effect": "allow",
"resource": [f"qcs::vod:{REGION}:uid/{APP_ID}:prefix//{SUB_APP_ID}/{BUCKET_ID}/{OBJECT_KEY}"],
}
],
"version": "2.0",
}

req = models.CreateStorageCredentialsRequest()
req.SubAppId = SUB_APP_ID
req.Policy = urllib.parse.quote(json.dumps(policy))

# 3. Apply for upload credentials
resp = vod_cli.CreateStorageCredentials(req)
creds = resp.Credentials
return Credential(
access_key_id=creds.AccessKeyId,
secret_access_key=creds.SecretAccessKey,
session_token=creds.SessionToken,
)

Using SDK to Upload Files

Below is an introduction to adapting common client SDKs to upload files to Professional Edition application buckets.

Domain

Professional Edition preset an upload acceleration domain for each application. All buckets in the application can use this domain for uploads.
Example application upload acceleration domain: 1234567890.vodpro-upload.com.

Uploading Files Using VOD SDK

App clients use obtained credentials to upload files to Tencent Cloud VOD Professional Edition storage. For details, see: Flutter Upload SDK.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백