Upload URLs and credentials are issued by ApsaraVideo for VOD for authorizing users to upload media files to the bucket allocated by ApsaraVideo for VOD. To ensure correct authorization and eliminate security risks during the upload process, you can use upload credentials, preventing malicious users from uploading media files.In addition, ApsaraVideo for VOD automatically creates media asset information when issuing upload URLs and credentials. The media asset information refers to media IDs (MediaId) and sometimes video or image IDs (VideoId or ImageId). A media ID is used to track and manage the lifecycle of a media file. The initial status of a media file is generally
Uploading. After being processed, the media file automatically transits to the next status such as Uploaded, Transcoding, or Normal. You can also use a media ID to initiate processing such as transcoding, snapshot taking, video AI processing, and video editing.
An upload URL and credential can only be used for a single media file. If multiple media files use the same upload URL and credential, these media files overwrite each other. Other restrictions for using upload URLs and credentials are as follows:
For the same video, different upload URLs and credentials are issued for repeated requests.
An upload URL (that is, the location where the uploaded file is stored) is automatically allocated by ApsaraVideo for VOD and cannot be specified at will.
The validity period of an upload credential is
The system may take a long period of time to upload a large video file. The upload credential may expire during the upload of the video file. You need to update the upload credential after it expires. The validity period of the new upload credential is still 3000 seconds. In this scenario, the upload URL remains unchanged.
An image file or an attached media asset file (such as a watermark or subtitle file) is relatively small. If the upload credential for such a file expires, you need to obtain a new upload credential.
The process of obtaining the upload URL and credential is a core process in ApsaraVideo for VOD. It is required in each upload operation. In most cases, you need to obtain the upload URL and credential. If you are using a server upload SDK, you do not need to obtain the upload URL and credential.
Upload by using a client upload SDK: You need to obtain the upload URL and credential. You do not need to parse the upload URL and credential. You only need to deliver them to the client.
Upload by using the API: You need to obtain the upload URL and credential, and parse and use them. That is, you need to implement the entire upload logic.
Upload by using the OSS native SDK: You need to obtain the upload URL and credential, and parse and use them. That is, you need to implement the entire upload logic. Note that you cannot use only the OSS native SDK to upload files. If you use only the OSS native SDK to upload files, the media asset information cannot be created.
Upload by using a server upload SDK: A server upload SDK has implemented the logic for obtaining the upload URL and credential. You do not need to obtain the upload URL and credential. However, server upload SDKs are available only for certain development languages.
Upload credentials are classified into video, image, and attached media asset upload credentials. Related API operations include:
We recommend that you use a server SDK to obtain upload credentials by calling the API. This method is simple and efficient. For more information, see the
SDK example for each API operation.
By default, you do not need to parse the upload URL and credential. You do not need to care about how the upload URL and credential are parsed either. If you want to implement upload based on the OSS native SDK or API, you need to parse the upload URL and credential.
Use Base64 to decode the upload URL (UploadAddress) and upload credential (UploadAuth) to obtain the OSS upload URL and authorization information.
- After the UploadAddress parameter is Base64 decoded, you can obtain a JSON string that contains the parameters listed in the following table.
|Bucket||The name of the OSS bucket.|
|Endpoint||The OSS URL.|
|FileName||The media file name that is allocated.|
- After the UploadAuth parameter is Base64 decoded, you can obtain a JSON string that contains the parameters listed in the following table.
|AccessKeyId||The ID of the key for upload authorization.|
|AccessKeySecret||The key for upload authorization.|
|SecurityToken||The security token for upload authorization.|
|Expiration||The validity period for upload authorization. For a video upload credential, the validity period is 3000 seconds. You need to update the upload credential after it expires.|
For more information, see Use the OSS SDK to upload videos to ApsaraVideo for VOD.