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.
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. |
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 |
| 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 |
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. |
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.
A user deploys an authorization service on an application server, such as ApsaraVideo VOD SDK, to obtain upload URLs and credentials.
A client sends a request to the application server to request an upload URL and an upload credential.
The application server sends a request to ApsaraVideo VOD to request the upload URL and credential.
ApsaraVideo VOD returns the upload URL and credential.
NoteApsaraVideo 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.
The application server returns the upload URL and credential to the client.
NoteThe application server does not need to perform Base64 decoding on the upload URL or credential.
The client uses the upload URL and credential to initialize an upload instance.
The client constructs upload parameters to send an upload request.
OSS returns the upload result.
NoteYou 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.
A user deploys an authorization service on an application server, such as ApsaraVideo VOD SDK, to obtain temporary STS tokens.
A client sends a request to the application server to request an STS token.
The application server sends a request to STS to request the STS token.
STS returns the token.
The application server returns the STS token to the client.
The client uses the STS token to initialize an upload instance.
The client constructs upload parameters to send an upload request.
OSS returns the upload result.
NoteYou 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: