This topic describes how to use the server upload SDK for C or C++ to upload media files to ApsaraVideo VOD.
Upload process
The upload SDK for C or C++ follows the general process of ApsaraVideo VOD SDKs. For more information, see Upload process. The following content describes the basic process of using the server upload SDK for C or C++:
Complete the configurations as described in the Prerequisites section.
Integrate the server upload SDK for C or C++. For more information, see Integrate the server upload SDK for C or C++.
Configure upload information to implement the upload logic.
For more information about how to upload audio or video files, see Scenario 1: Upload audio and video files.
For more information about how to upload images, see Scenario 2: Upload images.
For more information about how to upload auxiliary media assets, see Scenario 3: Upload auxiliary media assets.
Prerequisites
ApsaraVideo VOD is activated. For more information, see Activate ApsaraVideo VOD.
The system settings required for the upload, including the storage path in the specified region and the callback settings, are configured. For more information, see Manage storage buckets and Configure callbacks.
A RAM user is created and used to access ApsaraVideo VOD. To prevent security risks caused by the leakage of the AccessKey pair of your Alibaba Cloud account, we recommend that you create a RAM user and grant the RAM user the permissions required to access ApsaraVideo VOD. Then, you can use the AccessKey pair of the RAM user to access ApsaraVideo VOD. For more information, see Create and grant permissions to a RAM user.
Optional. A role is created for the RAM user and the role is granted the permissions required to access ApsaraVideo VOD if you want to access ApsaraVideo VOD by using Security Token Service (STS). For more information, see Use STS to upload videos.
NoteFor more information about the scenarios in which STS can be used, see Comparison between credentials and STS.
Integrate the server upload SDK for C or C++
The server upload SDK for C or C++ can be installed only in the Linux operating system.
In this example, the SDK V1.0.0 is used. You can use other versions based on your business requirements.
For more information about the directories of the server upload SDK for C or C++ and sample code, see Directories.
This topic describes how to install the server upload SDK for C or C++ as a non-root user and provides examples of installation commands.
The following table describes the required software packages and their usage, and installation examples.
Software package | Description | Installation by using YUM | Installation by using packages downloaded over the Internet |
CMake | A third-party compiler. |
|
|
libcurl | Troubleshoots network connection issues. |
|
|
libuuid | Generates UUIDs. | Sample code:
| N/A |
apr | N/A | Sample code:
|
|
apr-util | Manages memory usage and cross-platform issues. | Sample code:
|
|
minixml | Parses data that is returned in the XML format. | Sample code:
|
|
jsoncpp | Parses data that is returned in the JSON format. | Sample code:
|
|
OSS SDK | Before you use the server upload SDK for C or C++, you must download and install Object Storage Service (OSS) SDK for C or C++. | N/A | For more information about the download link and installation procedure, see Installation. Important If some OSS dependencies have been installed, you do not need to install them again. |
Upload SDK for C or C++ | N/A | Download link: Upload SDK Sample code:
|
Update the upload SDK for C or C++
If new operations or new features of existing operations are unavailable in the current SDK, update the SDK to the latest version. For more information, see Upload SDK.
You can obtain the version number and release date of the current SDK from the ChangeLog.txt file in the aliyun-c-sdk-vod directory.
Directories
/VodSDK-C_1.0.0.gz/VodSDK-C_1.0.0/aliyun-c-sdk-vod/src/upload.h
Directory | Description |
CreateUploadVideoRequest | The request class for video upload. For more information about the parameters, see CreateUploadVideo. |
CreateUploadImageRequest | The request class for image upload. For more information about the parameters, see CreateUploadImage. |
CreateUploadAttachedMediaRequest | The request class for the upload of auxiliary media assets. For more information about the parameters, see CreateUploadAttachedMedia. |
UploadOptions | The upload parameter structure. The following items describe the parameters.
|
uploadLocalVideo | The API operation used to upload local videos. |
uploadWebVideo | The API operation used to upload online videos. |
uploadLocalImage | The API operation used to upload local images. |
uploadWebImage | The API operation used to upload online images. |
uploadLocalAttachedMedia | The API operation used to upload local auxiliary media assets. |
uploadWebAttachedMedia | The API operation used to upload online auxiliary media assets. |
uploadLocalM3u8 | The API operation used to upload local M3U8 videos. |
uploadWebM3u8 | The API operation used to upload online M3U8 videos. |
/VodSDK-C_1.0.0.gz/VodSDK-C_1.0.0/aliyun-c-sdk-vod/samples
Directory | Description |
uploadVideo.cpp | The sample code for uploading videos. |
uploadImage.cpp | The sample code for uploading images. |
uploadAttachedMedia.cpp | The sample code for uploading auxiliary media assets. |
Scenario 1: Upload audio and video files
Regular audio and video files
ApsaraVideo VOD allows you to upload audio or video files by using one of the following methods:
Use multipart upload to upload a local file. You can upload a file of up to 48.8 TB in size. Resumable upload is not supported. For more information, see the testUploadLocalVideo function in the sample code.
Use the file URL to upload an online file. You can upload a file of up to 48.8 TB in size. Before you upload online files, you must download the files to a local disk. Make sure that the local disk has sufficient space. For more information, see the testUploadWebVideo function in the following sample code.