ApsaraVideo VOD allows you to upload media files from mobile terminals to Object Storage Server (OSS) buckets allocated by ApsaraVideo VOD. ApsaraVideo VOD provides client upload SDKs and the demos. 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 in scenarios of uploading user-generated content (UGC) and professionally generated content (PGC). Client upload SDKs support the upload of local and online files.
Note The upload SDK for Android also supports the upload of 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

N/A
Supported media files

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

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

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 in size.
  • You can upload an online media file of up to 5 GB in size.
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 locations

Upload SDKs allow you to use the default or specified storage location.

The default storage location can be changed. For more information, see Manage VOD resources.

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

You can specify the storage location by setting the StorageLocation parameter when you call operations related to upload URLs and credentials.

Media asset management

You can configure media metadata, such as media titles, tags, categories, and thumbnails.

You can manage media metadata by setting parameters such as Title, Tags, CateId, and CoverURL when you call operations related to upload URLs and credentials.
Audio and video transcoding

You can specify transcoding templates or workflows.

You can also choose not to transcode media files.

You can configure transcoding by setting parameters such as TemplateGroupId and WorkflowId when you call operations related to upload URLs and credentials.
Upload management

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 where it is stopped.
Event notification

You can set callbacks to obtain notifications about upload events. For more information about supported event notifications, see Upload settings.

For more information about how to set callbacks, see Configure callback settings.
Upload authorization

You can grant the upload permission 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 permission by using a Security Token Service (STS) token. In this case, you need to use an STS token to initialize an upload instance.

If you use upload SDKs for mobile terminals or web, we recommend that you grant the upload permission by using an STS token.

If you grant the upload permission by using an STS token, you must deploy a service to obtain STS tokens.

Client upload SDKs provide sample code of refreshing STS tokens.

Upload acceleration

You must enable the upload acceleration feature to use this feature. To enable this feature, submit a ticket.

After you enable this feature, you can configure this feature by setting the AccelerateConfig parameter in the UserData parameter when you call operations related to upload URLs and credentials.

Network type 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 identify the network type by yourself.

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 the following authorization methods:
  • Authorization based on upload URLs and credentials. We recommend that you use a server operation SDK of ApsaraVideo VOD to obtain upload URLs and credentials.
  • Authorization based on STS token. If you use this method, you must create a RAM role with specified permissions, assign the RAM role to a RAM user, and deploy an STS authorization service.

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

  1. A user deploys an authorization service on an application server, such as ApsaraVideo VOD sever operation 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.
    • Make sure that you safely preserve the media ID. You will need it in scenarios such as media asset management, audio or video playback, and media processing.
  5. The application server returns the upload URL and credential to the client.
    Notice 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

  1. A user deploys an authorization service on an application server, such as ApsaraVideo VOD sever operation 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 STS 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 about how to use different types of SDKs, see the following topics: