This topic describes the upload feature provided by the short video SDK for Android and how to use the SDK to upload media files.
Overview
ApsaraVideo VOD allows you to upload media files such as audio, video, and image files to Object Storage Service (OSS) buckets allocated to ApsaraVideo VOD. For more information, see Overview. The upload SDK provides a set of operations to implement the upload feature. You can use the AliyunIVodCompose core class to produce and upload edited videos on a dedicated user interface (UI). The Alibaba Cloud short video SDK allows you to call the core class AliyunIVodCompose to upload videos.
Supported editions
Edition | Supported |
---|---|
Professional | Yes |
Standard | Yes |
Basic | No |
Related classes
Class | Description |
---|---|
AliyunIVodCompose | The core class of the upload feature. You can use the core class to initialize an upload instance, upload video or image files, as well as update upload credentials. |
AliyunComposeFactory | The factory class. |
Video upload process
- If a user wants to use a client, such as an application or a web client, to upload a video or image by using the upload SDK, the client sends a request to the user application server to obtain the upload address and credentials.
- The application server initiates requests to ApsaraVideo VOD by calling the CreateUploadVideo or CreateUploadImage operation.
- If requests are successful, ApsaraVideo VOD returns the upload address, upload credentials, VideoId, and ImageURL to the application server.
- The application server returns the upload address and upload credentials to the client.
- The user uploads files from the local computer to OSS buckets by using the upload address and credentials.
- OSS returns the upload results.
Initialize an instance
// Create an instance.
AliyunComposeFactory.createAliyunVodCompose();
// Initialize the instance.
AliyunIVodCompose.init(Context context);
Obtain the video based on the upload address and credentials
Upload media files
// Upload a video or an image based on the upload address and credentials.
// videoPath: the address of the video file. Make sure that the address of the video file that you entered is the same as the address that you obtained.
// imagePath: the address of the image file. Make sure that the address of the image file that you entered is the same as the address that you obtained.
// uploadAddress: the upload address.
// uploadAuth: the upload credentials. If the credentials expire, update the upload credential.
// aliyunVodUploadCallBack: the upload callback.
// Upload the video.
AliyunIVodCompose.uploadVideoWithVod(String videoPath, String uploadAddress, String uploadAuth, AliyunIVodUploadCallBack aliyunVodUploadCallBack);
// Upload the image.
AliyunIVodCompose.uploadImageWithVod(String imagePath, String uploadAddress, String uploadAuth, AliyunIVodUploadCallBack aliyunVodUploadCallBack);
Update upload credentials
// Update upload credentials. uploadAuth: the upload credentials.
AliyunIVodCompose.refreshWithUploadAuth(String uploadAuth);
Release resources
AliyunIVodCompose.release();
Manage the upload process
// Pause the upload.
AliyunIVodCompose.pauseUpload();
// Continue the upload.
AliyunIVodCompose.resumeUpload();
// Cancel the upload.
AliyunIVodCompose.cancelUpload();