You can upload media files from application servers to Object Storage Service (OSS) buckets allocated by ApsaraVideo VOD. ApsaraVideo VOD provides server upload SDKs for common programming languages and demos on how to use these SDKs. Server upload SDKs encapsulate the logic for obtaining upload URLs and credentials. You need to only set simple configurations and then can use the SDKs to start uploads. This topic describes the scenarios, upload process, and integration and usage of server upload SDKs.
You can use server upload SDKs if you require automatic upload or want to upload a large number of video files or online media files. To upload online media files, you must download the files to an application server and then upload the files to ApsaraVideo VOD from the application server.
Java, Python, PHP, and C or C++ are supported.
|For other programming languages, use OSS SDKs. For more information, see Upload media files by using OSS SDKs.|
For information about supported media file formats, see Supported media file formats.
You can upload local media files and online media files. Online media files support only URL-based uploads.
Before you use URLs to upload files, you must encode the URLs to prevent upload failures caused by special characters in the URLs.
You can use the default storage location or specify a storage location.
You can change the default storage location. For more information, see Manage VOD storage.
The URL-based upload is supported only in the China (Shanghai) region.
You can specify the storage location by setting the StorageLocation parameter in an API operation used to obtain an upload URL and credential.
|Upload over an internal network||
If you need to deploy the upload script on an Elastic Compute Service (ECS) instance, you can specify the region in which the ECS instance resides in the upload logic. If the region of the ECS instance is the same as the storage region of ApsaraVideo VOD, files are automatically uploaded over an internal network. This speeds up uploads and reduces Internet traffic.
|ApsaraVideo VOD provides only public endpoints for you to use the API. Therefore, you must use an ECS instance that can access the Internet to deploy the upload script.|
You can configure the metadata of a media file, such as the title, tags, category, and thumbnail.
|You can configure the metadata of a media file by setting parameters, such as Title, Tags, CateId, and CoverURL, in an API operation used 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, in an API operation used to obtain an upload URL and credential.|
You can configure the upload progress bar and use the default or custom progress callbacks.
The server upload SDK for Java supports resumable uploads, whereas the server upload SDKs for other programming languages do not.
|You cannot configure the upload progress bar for M3U8 files.|
You can configure callbacks to receive notifications about upload events. For more information about supported event notifications, see Upload settings.
|For more information about how to configure the callbacks, see Configure callbacks.|
You can use an upload credential for upload authorization. Specifically, you can use the AccessKey pair of your Alibaba Cloud account or that of an authorized RAM user to initialize an upload instance.
You can use a Security Token Service (STS) token for upload authorization. Specifically, you can use an STS AccessKey pair to initialize an upload instance.
To use an STS token for upload authorization, you must create a service and obtain the STS AccessKey pair.
Upload acceleration is supported after you enable the upload acceleration feature. To enable the feature, submit a ticket.
After you enable the feature, you can configure upload acceleration by setting the
Integrate a server upload SDK into your application server and complete the upload settings. For example, configure the AccessKey pair, file path, storage location, media asset information, transcoding settings, and upload control settings.
The application server uses the server upload SDK to call an API operation to obtain an upload URL, an upload credential, and media asset information.Note Alternatively, you can construct an HTTP or HTTPS request to obtain an upload URL and credential. However, this method requires you to construct a signature and may easily cause errors. ApsaraVideo VOD provides the following API operations used to obtain upload URLs and credentials:
ApsaraVideo VOD delivers the upload URL, upload credential, and media ID to the application server.Note
In addition to the upload URL and credential, ApsaraVideo VOD automatically creates the media ID for media processing or the lifecycle management of the media asset.
- If the media asset to be uploaded is a video, ApsaraVideo VOD returns the media ID
- If the media asset to be uploaded is an image, ApsaraVideo VOD returns the media ID
- If the media asset to be uploaded is an auxiliary media asset, ApsaraVideo VOD returns
the media ID in the
- The media ID is used for media asset management, audio and video playback, and media processing. Keep the media ID safe.
- If the media asset to be uploaded is a video, ApsaraVideo VOD returns the media ID in the
The application server starts the upload based on the OSS upload logic encapsulated by the server upload SDK.
- OSS returns the upload result.
Note You can also configure a callback in advance to listen to the upload result.
Differences between server upload SDKs and server operation SDKs
The server upload SDKs and server operation SDKs provided by ApsaraVideo VOD are different. The server upload SDKs encapsulate the complete upload logic. You can integrate the upload SDKs and start uploads. The server operation SDKs integrate all features of ApsaraVideo VOD. In terms of the upload feature, the server operation SDKs encapsulate only the logic to obtain an upload URL and credential. If you use the server operation SDKs to upload media files, you must develop the upload logic. For example, you must obtain an upload URL and credential from ApsaraVideo VOD, decode the Base64-encoded upload URL and credential, and use OSS features to complete an upload. For more information about server operation SDKs provided by ApsaraVideo VOD, see Server operation SDK reference.