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 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 addresses

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

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

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 media metadata, such as media titles, tags, categories, and thumbnails.

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 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 or web clients, 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 that can be used to update STS tokens.

Upload acceleration

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

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 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

The following figure shows the complete process of uploading a media file by using an upload URL and an upload credential. In this example, a server operation SDK of ApsaraVideo VOD is integrated to obtain the upload URL and credential.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.
    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

The following figure shows the complete process of uploading a media file by using an STS token.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: