Uploads a media file to ApsaraVideo VOD based on the URL of the source file. The media file can be an audio file or a video file. You can also call this operation to upload multiple media files at a time.
Operation Description
- If a callback is configured, you can receive an UploadByURLComplete event notification after the media file is uploaded. You can query the upload status by calling the GetURLUploadInfos operation.
- After an upload job is submitted, the job is asynchronously executed on the cloud. All submitted upload jobs are queued for execution. You can check the job status based on the URL and media file ID that are returned in the event notification.
- You can call the UploadMediaByURL operation if the media file is not stored on a local server or terminal and needs to be uploaded by using a URL that can be accessed from the Internet.
- You can call the UploadMediaByURL operation only in the China (Shanghai) region.
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
vod:UploadMediaByURL | Write |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
UploadURLs | string | Yes | The URL of the source file.
| https://****.mp4 |
TemplateGroupId | string | No | The ID of the transcoding template group. You can use one of the following methods to obtain the ID of the transcoding template group:
Note UploadMetadatas parameter. If you set this parameter and the nested TemplateGroupId parameter, the value of the nested TemplateGroupId parameter takes effect. | ca3a8f6e4957b65806709586**** |
StorageLocation | string | No | The storage location of the media file. Log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Configuration Management > Media Management > Storage. On the Storage page, you can view the storage location. If you do not specify the storage location, the default storage location is used. | outin-bfefbb90a47c******163e1c7426.oss-cn-shanghai.aliyuncs.com |
UploadMetadatas | string | No | The metadata of the media file to be uploaded. The value is a JSON string.
| [{"SourceURL":"https://example.aliyundoc.com/video01.mp4","Title":"urlUploadTest"}] |
UserData | string | No | The custom configurations, including callback configurations and upload acceleration configurations. The value is a JSON string. For more information, see the "UserData: specifies the custom configurations for media upload" section of the Request parameters topic. Note | {"MessageCallback":{"CallbackURL":"http://example.aliyundoc.com"},"Extend":{"localId":"xxx","test":"www"}} |
AppId | string | No | The ID of the application. Default value: app-1000000. For more information, see Overview. | app-**** |
WorkflowId | string | No | The ID of the workflow. To view the ID of the workflow, log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Configuration Management > Media Processing > Workflows. NoteIf both the WorkflowId and TemplateGroupId parameters are set, the value of the WorkflowId parameter takes effect. For more information, see Workflows. | e1e243b42548248197d6f74f9**** |
UploadMetadata
Parameter | Type | Required | Description |
---|---|---|---|
SourceURL | String | Yes | The URL of the source file to be uploaded. |
Title | String | Yes | The title of the media file. The title can be up to 128 bytes in length. The value must be encoded in UTF-8. |
FileSize | String | No | The size of the media file. |
Description | String | No | The description of the media file. The description can be up to 1,024 bytes in length. The value must be encoded in UTF-8. |
CoverURL | String | No | The URL of the custom thumbnail of the media file. |
CateId | String | No | The category ID of the media file. To view the category ID of the media file, log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Configuration Management > Media Management > Categories. |
Tags | String | No | The one or more tags of the media file. Each tag can be up to 32 bytes in length. You can set a maximum of 16 tags. Separate multiple tags with commas (,). The value must be encoded in UTF-8. |
TemplateGroupId | String | No | The ID of the transcoding template group. If both the request parameter TemplateGroupId and the nested parameter TemplateGroupId are set, the value of the nested parameter takes effect. |
WorkflowId | String | No | The ID of the workflow. If both the WorkflowId and TemplateGroupId parameters are set, the value of the WorkflowId parameter takes effect. For more information, see Workflows. |
FileExtension | String | No | The file name extension of the media file. For more information about file name extensions supported by ApsaraVideo VOD, see Overview. |
- If you set the TemplateGroupId parameter to VOD_NO_TRANSCODE to upload videos, only the videos in the format of MP4, FLV, MP3, M3U8, or WebM can be played. Videos in the other formats are supported only for storage. You can identify the video format based on the file name extension. If you want to use ApsaraVideo Player, the version must be 3.1.0 or later.
- If you set the TemplateGroupId parameter to VOD_NO_TRANSCODE, only the FileUploadComplete but not the StreamTranscodeComplete event notification is returned after the media file is uploaded.
- If a callback is configured, ApsaraVideo VOD sends an UploadByURLComplete event notification after the media file is uploaded, in addition to the FileUploadComplete and StreamTranscodeComplete event notifications.
- If you specify multiple media files at a time, ApsaraVideo VOD sends an event notification for each media file after the media file is uploaded.
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "25818875-5F78-4AF6-D7393642CA58****",
"UploadJobs": [
{
"SourceURL": "http://example****.mp4",
"JobId": "ad90a501b1b94fb72374ad005046****"
}
]
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation | ||||
---|---|---|---|---|---|---|
2023-05-16 | The input parameters of the API operation change. | |||||
|
Common errors
The following table describes the common errors that this operation can return.
Error code | Error message | HTTP status code | Description |
---|---|---|---|
InvalidParameter.UploadURLs | The specified parameter UploadURLs is not valid. | 400 | The error message returned because the UploadURLs parameter is invalid. |