All Products
Search
Document Center

Intelligent Media Services:Upload media assets by calling API operations of OSS

Last Updated:Sep 26, 2024

If media assets are online files or need to be automatically uploaded or migrated at a time, you can call the related API operations of Intelligent Media Services (IMS) to obtain upload URLs and upload credentials of the media assets and then call API operations of Object Storage Service (OSS) to upload the media assets. This topic describes how to upload media assets by calling API operations of OSS.

Prerequisites

  • You have learned about the supported file formats. For more information, see the "Supported file formats" section of the Overview topic.

  • OSS is activated. For more information, see Activate OSS.

Background information

Before you call API operations of OSS to upload media assets, you must obtain upload URLs and upload credentials of the media assets. An upload URL is an OSS storage address in IMS. An upload credential is an authorization credential that is used to complete an upload. Upload URLs and upload credentials are issued by IMS and are used to resolve authorization and security issues during a media asset upload. This prevents malicious file uploads. When IMS issues an upload URL and an upload credential, a media asset ID is automatically created for subsequent media asset lifecycle management or media processing.

Usage notes

  • You can upload an audio or video file of up to 5 GB in size.

  • File name extensions are not case-sensitive during the upload. If a file name extension is not supported or the format of an uploaded file does not match an upload credential, the file fails to be uploaded.

Step 1: Obtain an upload URL and an upload credential of a media asset

You can integrate server SDKs or create HTTP or HTTPS requests to call the CreateUploadMedia operation to obtain an upload URL and an upload credential of a media asset. We recommend that you integrate server SDKs. For more information, see Request syntax and signature method V2 for RPC APIs.

Important
  • An upload URL and an upload credential can be used for only one media asset. If the upload URL and the upload credential are used for another media asset, the original media asset is overwritten.

  • If you repeatedly obtain an upload URL and an upload credential of a media asset, the upload URLs and upload credentials obtained each time are different.

  • Upload URLs are automatically assigned by IMS and cannot be customized.

  • The validity period of an upload credential is 3,000 seconds. If the size of a video file is large, an upload credential of the video file may expire during the upload. In this case, you can call the RefreshUploadMedia operation to refresh the upload credential. After you refresh the upload credential, the validity period of the new upload credential is still 3,000 seconds and the upload URL remains unchanged.

  • The size of images and auxiliary media assets including subtitle and font files is small. After an upload credential of an image or an auxiliary media asset expires, you must reobtain an upload credential.

Step 2: Call an API operation of OSS to upload the media asset

After the upload URL and the upload credential of the media asset is Base64-decoded, call the related API operation of OSS to upload the media asset. For more information, see Common HTTP headers and Upload objects to an OSS bucket.

API references