All Products
Search
Document Center

ApsaraVideo VOD:Client upload SDKs

Last Updated:Jun 14, 2024

ApsaraVideo VOD allows you to upload media files directly from mobile clients to ApsaraVideo VOD. Compared with uploading media files by using the application server, uploading media files directly from a client saves server resources because you do not need to send the files to the application server and upload the files from the server. This topic describes the scenarios in which the client upload SDKs can be used and how to use the client upload SDKs.

Scenarios

Client upload SDKs can be used to upload user-generated content (UGC) and professionally generated content (PGC). Client upload SDKs allow you to upload local files and online files.

Note

The upload SDK for Android also allows you to upload short videos. You can use a VODSVideoUploadClient instance to upload a short video and video thumbnail at a time.

Feature

Description

Remarks

Supported clients

Web, iOS, Android, and WeChat mini program

None.

Supported media files

For more information about the formats of media files that can be uploaded, see Overview.

You can upload local files and online files. Online files are uploaded by using the URLs.

You can record and upload short videos.

You can upload multiple files at a time and manage the file list. You can add files to or remove files from the list, cancel or resume the upload of files, and traverse or clear the list.

  • You can upload a local media file of up to 48.8 TB.

  • You can upload an online file of up to 5 GB.

Note

To upload media files by using URLs, you must encode the URLs. This prevents upload failures caused by special characters in the URLs.

Storage address setting

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

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

The URL-based upload is supported only in the China (Shanghai) region.

You can specify the storage address by setting the StorageLocation parameter when you call an operation to obtain an upload URL and credential.

Media asset management

You can configure the metadata of a media file, such as the title, tags, category, and thumbnail.

You can configure the metadata by setting parameters such as Title, Tags, CateId, and CoverURL when you call an operation to obtain an upload URL and credential.

Audio and video transcoding

You can specify a transcoding template or workflow to transcode uploaded audio and video files.

You can also upload audio and video files without transcoding.

You can configure transcoding by setting parameters such as TemplateGroupId and WorkflowId when you call an operation to obtain an upload URL and credential.

Upload control

You can start, stop, pause, and resume the upload.

ApsaraVideo VOD supports resumable upload.

Resumable upload is implemented by upload SDKs. If a video fails to be uploaded due to exceptions, the upload is resumed from the point in time when the upload is stopped.

Event notifications

You can configure callbacks to receive notifications for upload events. For more information about supported event notifications, see Upload settings.

For more information about how to configure callbacks, see Configure callbacks.

Upload authorization

  • You can grant the upload permissions by using an upload credential. In this case, you need to use an AccessKey pair of an Alibaba Cloud account or an authorized RAM user to initialize an upload instance.

  • You can also grant the upload permissions by using a Security Token Service (STS) token. In this case, you need to use an STS token to initialize an upload instance.

We recommend that you grant the upload permissions by using an upload credential. For more information, see Comparison between credentials and STS.

Upload acceleration

You must enable the upload acceleration feature to use this feature. To enable the upload acceleration feature, submit a request on Yida.

After you enable this feature, you can configure the feature by setting AccelerateConfig in UserData when you call an operation to obtain an upload URL and credential.

Network switching

You can switch between a 3G or 4G mobile network and Wi-Fi.

To reduce data usage in 3G or 4G networks, you can pause the upload when the network switches to 3G or 4G and resume the upload when the network switches back to Wi-Fi. You must specify the network type based on your business requirements.

Note

ApsaraVideo VOD provides the following operations related to upload URLs and credentials:

Upload processes

Client upload SDKs encapsulate the logic of uploading files to OSS buckets. When you upload medial files from clients, the files are directly uploaded to OSS buckets allocated by ApsaraVideo VOD without forwarding by servers. Therefore, the clients must be authenticated. You must deploy an authorization service on your application server to obtain upload URLs and credentials. Client upload SDKs support authorization based on upload credentials and authorization based on STS tokens. We recommend that you use an upload credential. For more information, see Comparison between credentials and STS.

Process of uploading a media file by using an upload URL and an upload credential

The following figure shows the complete process of uploading a media file by using an upload URL and an upload credential. In this example, ApsaraVideo VOD SDK is integrated to obtain the upload URL and credential.客户端SDK上传凭证上传流程

  1. A user deploys an authorization service on an application server, such as ApsaraVideo VOD SDK, to obtain upload URLs and credentials.

  2. A client sends a request to the application server to request an upload URL and an upload credential.

  3. The application server sends a request to ApsaraVideo VOD to request the upload URL and credential.

  4. ApsaraVideo VOD returns the upload URL and credential.

    Note

    ApsaraVideo VOD also generates media IDs, which can be used in media lifecycle management and media processing.

    • For a video, the media ID is returned in the VideoId parameter.

    • For an image, the media ID is returned in the ImageId parameter.

    • For an auxiliary media asset, the media ID is returned in the MediaId parameter.

    • Properly keep the returned media IDs, which are required in subsequent tasks, such as media asset management, audio and video playback, and media processing.

  5. The application server returns the upload URL and credential to the client.

    Note

    The application server does not need to perform Base64 decoding on the upload URL or credential.

  6. The client uses the upload URL and credential to initialize an upload instance.

  7. The client constructs upload parameters to send an upload request.

  8. OSS returns the upload result.

    Note

    You can also set callbacks in advance to receive notifications about upload events.

Process of uploading a media file by using an STS token

If you use authorization based on the STS token, you must create a RAM role and grant the RAM role permissions to access ApsaraVideo VOD. For more information, see Use STS to upload videos.

The following figure shows the complete process of uploading a media file by using an STS token.客户端STS方式上传流程

  1. A user deploys an authorization service on an application server, such as ApsaraVideo VOD SDK, to obtain temporary STS tokens.

  2. A client sends a request to the application server to request an STS token.

  3. The application server sends a request to STS to request the STS token.

  4. STS returns the token.

  5. The application server returns the STS token to the client.

  6. The client uses the STS token to initialize an upload instance.

  7. The client constructs upload parameters to send an upload request.

  8. OSS returns the upload result.

    Note

    You can also set callbacks in advance to receive notifications about upload events.

References

The procedure of integrating and using client upload SDKs varies with the client. For more information, see the following topics: