Server-side upload

Updated at:

Server-side upload is the process of uploading media files from an application server to ApsaraVideo VOD. ApsaraVideo VOD provides server-side upload SDKs and demos for popular programming languages. The server-side upload SDK encapsulates the logic for obtaining upload URLs and credentials, which lets you upload files using a simple configuration. This topic describes the scenarios, upload process, and instructions for the server-side upload SDK.

Scenarios

The server-side upload SDK is suitable for scenarios such as automated uploads and batch migration of videos. It is also suitable for uploading online media files. To upload online media files, you must first download the files to your local server and then upload them to ApsaraVideo VOD.

Feature

Description

Notes

Supported languages

The supported programming languages include Java, Python, PHP, and C/C++.

For other languages, you can upload files using the native OSS SDK. For more information, see Upload files using the OSS SDK.

Media description

For information about supported media formats, see Overview of media upload.

You can upload local files or pull online files from a URL.

  • Local files: A single file can be up to 48.8 TB.

  • Online files: A single file can be up to 5 GB.

Note

If you set a URL for an upload, you must encode the URL before you pass it to prevent upload failures that are caused by special characters.

Storage address

You can use the default storage address or specify a storage address.

You can modify the default storage address. For more information, see Manage storage buckets.

URL-based uploads are supported only in the China (Shanghai) region.

You can implement this by setting the StorageLocation parameter of the related API operations for obtaining upload URLs and credentials.

Internal network upload

If the upload script is deployed on an ECS instance, you can specify the region of the ECS instance in the upload logic. If the ECS region is the same as the ApsaraVideo VOD storage region, the upload is automatically performed over the internal network. This method is faster and reduces Internet traffic consumption.

Because the ApsaraVideo VOD API provides only public endpoints for access, the ECS server where the upload script is deployed must have internet access.

Media asset management

You can set metadata, such as the media title, tags, category, and thumbnail.

You can set metadata using parameters such as Title, Tags, CateId, and CoverURL in the related API operations for obtaining upload URLs and credentials.

Audio and video transcoding

You can transcode media by specifying a transcoding template or a workflow.

You can also choose not to transcode the media.

You can configure transcoding using parameters such as TemplateGroupId and WorkflowId in the related API operations for obtaining upload URLs and credentials.

Upload control

You can set an upload progress bar chart. Default and custom progress callbacks are supported.

Resumable uploads are supported for Java but not for other languages.

Setting an upload progress bar chart is not supported for M3U8 file uploads.

Event notifications

You can set callbacks to receive upload event notifications. For information about supported event notifications, see Overview of media upload.

To configure callbacks, see Configure callbacks.

Upload authorization

You can authorize uploads using upload credentials. You can use the AccessKey pair of an Alibaba Cloud account or an authorized Resource Access Management (RAM) user to initialize an upload.

You can also authorize uploads using Security Token Service (STS). You can use a temporary AccessKey pair from STS to initialize an upload.

If you use STS, you must build a service that obtains temporary AccessKey pairs from STS.

Upload acceleration

This feature is supported after you enable it. To enable upload acceleration, submit a ticket.

After you enable this feature, you can configure it using the AccelerateConfig parameter within the UserData parameter of the related API operations for obtaining upload URLs and credentials.

Upload process

The server-side upload SDK encapsulates the logic for obtaining upload URLs and credentials and the OSS upload logic. This lets you upload files using a simple configuration. The following figure shows the complete upload process. 服务端上传SDK流程

Process details

  1. Integrate the ApsaraVideo VOD server-side upload SDK into your application server and configure the upload settings. These settings include AccessKey information, file address, storage address, media asset management, transcoding settings, and upload control.

  2. The application server uses the ApsaraVideo VOD server-side upload SDK to call the related API operations for obtaining upload URLs and credentials to obtain the upload URL, upload credential, and media asset information.

    Note

    You can also construct an HTTP or HTTPS request to obtain the upload URL and credential. However, you must generate the signature yourself, which increases the risk of errors. The related API operations for obtaining upload URLs and credentials include the following:

  3. The ApsaraVideo VOD service returns information such as the upload URL (UploadAddress), upload credential (UploadAuth), and media ID in the response.

    Note

    When the ApsaraVideo VOD service issues the upload URL and credential, it also automatically creates media asset information, which is the media ID (MediaId). The media ID is used for media asset lifecycle management or media processing.

    • The VideoId returned by the operation to obtain the video upload URL and credential is the media ID.

    • The ImageId returned by the operation to obtain the image upload URL and credential is the media ID.

    • The MediaId returned by the operation to obtain the auxiliary media asset upload URL and credential is the media ID.

    • You must save the media ID because it is used as an input for media asset management, audio and video playback, and media processing.

  4. The application server starts the upload using the OSS upload logic that is encapsulated in the ApsaraVideo VOD server-side upload SDK.

  5. The OSS service returns the upload result.

    Note

    You can also listen for the upload result by configuring callbacks in advance to receive upload-related events.

Instructions

The integration and usage methods for server-side upload SDKs vary based on the programming language. For specific instructions, see the following topics:

Differences between the ApsaraVideo VOD server-side upload SDK and the ApsaraVideo VOD server-side SDK

The ApsaraVideo VOD server-side upload SDK is different from the ApsaraVideo VOD server-side SDK. The ApsaraVideo VOD server-side upload SDK encapsulates the complete upload logic and can be directly integrated and used. In contrast, the ApsaraVideo VOD server-side SDK integrates all features of ApsaraVideo VOD. Its upload feature provides only the logic for obtaining the upload URL and credential. You must implement the upload logic based on your specific scenario. This includes obtaining the upload credential and URL from the ApsaraVideo VOD service, Base64-decoding the upload credential and URL, and calling OSS to complete the upload. For more information about the ApsaraVideo VOD server-side SDK, see ApsaraVideo VOD server-side SDK.