Help Center/ Video On Demand/ API Reference/ Media Asset Upload/ Uploading Media Files to VOD
Updated on 2026-01-16 GMT+08:00

Uploading Media Files to VOD

Function

When calling this API to create a media asset, you need to upload the corresponding media file to the OBS bucket of VOD.

If the media file to be uploaded is smaller than 20 MB, use the PUT method to upload the file to the URL returned by the API. For details, see Example 1: Uploading a Media File Less Than 20 MB.

If the media file to be uploaded is greater than 20 MB, it must be split into binary streams before being uploaded. For details, see Example 2: Uploading a Media File Greater Than 20 MB by Part.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

URI

POST /v1.0/{project_id}/asset

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

User token. This parameter is mandatory when token authentication is used.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Authorization

No

String

Authentication information. This parameter is mandatory for AK/SK authentication.

X-Sdk-Date

No

String

Time when a request is sent. This parameter is mandatory for AK/SK authentication.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

title

Yes

String

Media asset title. The value is UTF-8 encoded and contains a maximum of 128 characters.

description

No

String

Video description. The value contains a maximum of 1024 characters.

video_name

Yes

String

Audio/Video file name. The value contains a maximum of 128 characters.

The file name extension is optional.

video_type

Yes

String

Uploaded audio/video file format.

The options include:

  • Video: MP4, TS, MOV, MXF, MPG, FLV, WMV, AVI, M4V, F4V, MPEG, 3GP, ASF, MKV, and WebM

  • Audio: MP3, OGG, WAV, WMA, APE, FLAC, AAC, AC3, MMF, AMR, M4A, M4R, WV, and MP2

If an audio file is uploaded, transcoding, watermarking, and subtitling are not supported.

category_id

No

Integer

Media asset category ID.

You can create a media asset category by calling the API for creating a media asset category or using the VOD console and obtain the category ID.

NOTE:
If this parameter is not specified or is set to -1, the uploaded audio/video files fall into the preconfigured Other category.

video_md5

No

String

You are advised to refer to the example of uploading and updating media files in "Generating an MD5 Value" in the appendix of API Reference.

cover_type

No

String

Thumbnail image format.

The options include:

  • JPG

  • PNG

The name of the uploaded thumbnail is fixed, and the extension is the abbreviation of the thumbnail file format, for example, cover0.jpg and cover1.png.

If the file format is not specified, the thumbnail file does not have a file name extension.

NOTE:
If the image format is specified, the first-frame snapshot will not be used as the thumbnail. You need to upload a thumbnail.

cover_md5

No

String

MD5 value of the thumbnail image file. You are advised to refer to the example of uploading and updating media files in "Generating an MD5 Value" in the appendix of API Reference.

subtitles

No

Array of Subtitle objects

Subtitle file information.

tags

No

String

Video tags.

Each tag contains up to 24 characters and up to 16 tags are allowed.

Use commas (,) to separate tags. All tags must be UTF-8 encoded.

auto_publish

No

Integer

Whether to publish the content automatically.

The options include:

  • 0: The content is not automatically published.

  • 1: The content is automatically published.

Default value: 1

template_group_name

No

String

Transcoding template group name.

If this parameter is specified, the specified transcoding template is used to transcode the uploaded audio/video. You can configure a transcoding template on the VOD console. For details, see "Transcoding Settings" in VOD User Guide.

NOTE:
If both template_group_name and workflow_name are specified, template_group_name takes effect.

auto_encrypt

No

Integer

Whether to automatically encrypt a file.

The options include:

  • 0: not encrypted

  • 1: encrypted

Default value: 0

Encryption and transcoding must be performed at the same time. If encryption is required, the transcoding parameters cannot be empty, and the transcoding output format must be HLS.

auto_preheat

No

String

Whether to automatically pre-load content to CDN.

The options include:

  • 0: The content is not automatically pre-loaded.

  • 1: The content is automatically pre-loaded.

Default value: 0

thumbnail

No

Thumbnail object

Snapshot parameters.

Note: You will be billed for the snapshots generated. To avoid snapshot costs, you can leave these parameters unspecified.

review

No

Review object

Media asset review parameters.

NOTE:
Only VOD in AP-Singapore supports this function.

workflow_name

No

String

Workflow name.

If this parameter is specified, the specified workflow is used to transcode the uploaded audio/video. You can configure a workflow on the VOD console. For details, see "Transcoding Settings" in VOD User Guide.

Table 4 Subtitle

Parameter

Mandatory

Type

Description

id

Yes

Integer

Subtitle ID.

Value range: [1, 16]

type

Yes

String

Subtitle file format. Currently, only SRT and VTT are supported.

language

Yes

String

Subtitle language.

name

No

String

Subtitle file name.

md5

No

String

MD5 value of the subtitle file.

description

No

String

Subtitle description.

Table 5 Thumbnail

Parameter

Mandatory

Type

Description

type

Yes

String

Snapshot capturing mode.

The options include:

  • time: Snapshots are captured by interval.

  • dots: Snapshots are captured at a specified time point.

  • quantity: Snapshots are captured based on the specified quantity and video duration.

quantity

No

Integer

This parameter is mandatory when type is set to quantity. Snapshots are captured based on the specified quantity and video duration.

Value range: an integer ranging from 1 to 10

quantity_time

No

Integer

This parameter is optional when type is set to quantity. Snapshots are captured based on the specified quantity at a specified interval.

Value range: an integer ranging from 0 to 2147483647

time

No

Integer

Interval at which snapshots are captured. Unit: seconds

This parameter is available when type is set to time.

Default value: 12

Value range: an integer ranging from 0 to 100

dots

No

Array of integers

This parameter is mandatory when type is set to dots. Array of time points when snapshots are captured.

cover_position

No

Integer

The value indicates which snapshot is specified as the thumbnail.

Default value: 1

format

No

Integer

Snapshot file format.

The options include:

  • 1: jpg

Default value: 1

aspect_ratio

No

Integer

Aspect ratio.

The options include:

  • 0: adaptive (the original aspect ratio is retained)

  • 1: 16:9

Default value: 0

max_length

No

Integer

The longest side of a snapshot.

Unit: pixel

The width of the snapshot is scaled proportionally with the longest side and input video pixel.

Default value: 480

Table 6 Review

Parameter

Mandatory

Type

Description

template_id

No

String

Review template ID. You can obtain the value after configuring the review template on the VOD console. For details, see "Review Settings" in VOD User Guide.

NOTE:
Only VOD in AP-Singapore supports this function.

interval

No

Integer

Snapshot check interval. The value range is (0,100]. This parameter is ignored in request parameters.

politics

No

Integer

Confidence of politically sensitive content moderation. The value can be -1 or range from 0 to 100. This parameter is ignored in request parameters.

A higher confidence score indicates a more reliable moderation result. If this function is disabled or the value is set to 0, this check is not performed. politics, terrorism, and porn cannot be set to 0 simultaneously.

terrorism

No

Integer

Confidence of terrorism-related content moderation. The value can be -1 or range from 0 to 100. This parameter is ignored in request parameters.

A higher confidence score indicates a more reliable moderation result. If this function is disabled or the value is set to 0, this check is not performed. politics, terrorism, and porn cannot be set to 0 simultaneously.

porn

No

Integer

Confidence of pornographic content moderation. The value can be -1 or range from 0 to 100. This parameter is ignored in request parameters.

A higher confidence score indicates a more reliable moderation result. If this function is disabled or the value is set to 0, this check is not performed. politics, terrorism, and porn cannot be set to 0 simultaneously.

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Type

Description

asset_id

String

Media asset ID.

video_upload_url

String

URL for uploading videos.

cover_upload_url

String

URL for uploading thumbnails.

subtitle_upload_urls

Array of strings

Array of URLs for uploading subtitle files.

target

File_addr object

Media asset storage parameters.

Table 8 File_addr

Parameter

Type

Description

bucket

String

OBS bucket name.

location

String

Name of the region where the bucket is located. For example, the region name of CN North-Beijing4 is cn-north-4. The created bucket must be in the same region as VOD.

object

String

File storage path.

Status code: 403

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error description.

Example Requests

This example creates a media asset.

POST https://{endpoint}/v1/{project_id}/asset

Content-Type: application/json
{
  "title": "Avatar test test",
  "description": "Avatar, test",
  "category_id": -1,
  "tags": "mytags",
  "video_name": "Avatar_480P.mp4",
  "video_type": "MP4",
  "video_md5": "a945d4b3d8fc317190a9332fe856f03d",
  "cover_type": "JPG",
  "cover_md5": "a655d4b3d8fc758691a9332fe387f26c",
  "auto_publish": 0,
  "subtitles": [
    {
      "id": 1,
      "language": "CN",
      "type": "SRT",
      "md5": "SqcyFjJZoDZaP8oKIY6rgQ==",
      "description": "AAAAA"
    }
  ]
}

Example Responses

Status code: 200

Returned when the request succeeded.

{
  "asset_id" : "f488337c31c8e4622f1590735b134c65",
  "video_upload_url" : "https://obs.cn-north-4.myhuaweicloud.com:443/obs-vod-1/%7Bproject_id%7D/f488337c31c8e4622f1590735b134c65/Avatar_480P.mp4?AWSAccessKeyId=CBN2J**********0RCSN&Expires=1518147618&Signature=kZYh0hEos2V**********AHGyXA%3D",
  "cover_upload_url" : "https://obs.cn-north-4.myhuaweicloud.com:443/obs-vod-1/%7Bproject_id%7D/f488337c31c8e4622f1590735b134c65/cover/Cover0.jpg?AWSAccessKeyId=CBN2J**********0RCSN&Expires=1518147619&Signature=kZYh0hEos2V**********AHGyXA%3D",
  "subtitle_upload_urls" : [ "https://obs-vod-1.obs.cn-north-4.myhuaweicloud.com:443/14ce1d4437164aba8b364ce15866154e/53a018d2dc53ca07eb5a07a839205c9d/subtitle/1.srt?AWSAccessKeyId=CBN2J**********0RCSN&Expires=1534760131&Signature=kZYh0hEos2V**********AHGyXA%3D" ],
  "target" : {
    "bucket" : "obs-vod-1",
    "location" : "cn-north-4",
    "object" : "093bb6b6c4fc460ab90a40d8b821dda3/a2053aef99725711dad3e02dc6cd5f89/0a9b70035b78b8a19c6d9e7c2693d93c.mp4"
  }
}

Status code: 403

Returned when the request failed.

{
  "error_code" : "VOD.10064",
  "error_msg" : "Media asset classification does not exist, please check."
}

Status Codes

Status Code

Description

200

Returned when the request succeeded.

403

Returned when the request failed.

Error Codes

See Error Codes.