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.

Usage notes

  • 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.

QPS limit

You can call this operation up to 200,000 times per day per account. If the number of calls per day exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. For more information, see QPS limits on API operations in ApsaraVideo VoD.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes UploadMediaByURL

The operation that you want to perform. Set the value to UploadMediaByURL.

UploadURLs String Yes https://****.mp4

The URL of the source file.

  • The URL must contain a file name extension, such as mp4 in https://****.mp4.
    • If the URL does not contain a file name extension, you can specify one by setting the FileExtension parameter under the UploadMetadatas parameter.
    • If the URL contains a file name extension and the FileExtension parameter is set, the value of the FileExtension parameter is used.
    • For more information about file name extensions supported by ApsaraVideo VOD, see Overview.
  • URL encoding is required. Separate multiple URLs with commas (,). You can specify a maximum of 20 URLs.
  • Special characters may cause upload failures. Therefore, encode URLs before you separate them with commas (,).
TemplateGroupId String No ca3a8f6e4957b65806709586****

The ID of the transcoding template group. You can use one of the following methods to obtain the ID of the transcoding template group:

  • Log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Configuration Management > Media Processing > Transcoding Template Groups. On the Transcoding Template Groups page, you can view the ID of the transcoding template group.
  • View the value of the TranscodeTemplateGroupId parameter returned by the AddTranscodeTemplateGroup operation that you called to create a transcoding template group.
  • View the value of the TranscodeTemplateGroupId parameter returned by the ListTranscodeTemplateGroup operation that you called to query a transcoding template group.
Note
  • If this parameter is left empty, the default transcoding template group is used for transcoding. If this parameter is set to a specific value, the specified transcoding template group is used for transcoding.
  • You can also specify the ID of the transcoding template group by using the nested TemplateGroupId parameter under the UploadMetadatas parameter. If you set this parameter and the nested TemplateGroupId parameter, the value of the nested TemplateGroupId parameter takes effect.
StorageLocation String No outin-bfefbb90a47c******163e1c7426.oss-cn-shanghai.aliyuncs.com

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.

UploadMetadatas String No [{"SourceURL":"https://example.aliyundoc.com/video01.mp4","Title":"urlUploadTest"}]

The metadata of the media file to be uploaded. The value is a JSON string.

  • This parameter takes effect only if the value of the SourceURL parameter matches the URL that is specified by the UploadURLs parameter.
  • The JSON-formatted data, such as [UploadMetadata, UploadMetadata,…], must be converted into a JSON string.
  • For more information, see the UploadMetadata section.
UserData String No null

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
  • The callback configurations take effect only if you specify the HTTP callback URL and select the specific callback events in the ApsaraVideo VOD console. For more information about how to configure HTTP callback settings in the ApsaraVideo VOD console, see Configure callback settings.

  • To use the upload acceleration feature, submit a ticket to enable this feature. For more information, see Overview.
AppId String No app-****

The ID of the application. Default value: app-1000000. For more information, see Overview.

WorkflowId String No e1e243b42548248197d6f74f9****

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.

Note If both the WorkflowId and TemplateGroupId parameters are set, the value of the WorkflowId parameter takes effect. For more information, see Workflows.

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.

Note
  • Do not include emoticons in the nested parameters, such as Title, Description, and Tags, under the UploadMetadata parameter.
  • 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

Parameter Type Example Description
RequestId String 25818875-5F78-4AF6-D7393642CA58****

The ID of the request.

UploadJobs Array of UploadJob

The information about one or more upload jobs.

SourceURL String http://****.mp4

The URL of the source file that is uploaded in the upload job.

JobId String ad90a501b1b94fb72374ad005046****

The ID of the upload job.

Note This operation is used to asynchronously upload media files. Upload jobs are queued for execution after they are submitted. The completion time of an upload job varies with the number of jobs in the queue.

Examples

Sample requests

http(s)://vod.cn-shanghai.aliyuncs.com/?Action=UploadMediaByURL
&UploadURLs=https://****.mp4
&TemplateGroupId=ca3a8f6e4957b65806709586****
&StorageLocation=outin-bfefbb90a47c******163e1c7426.oss-cn-shanghai.aliyuncs.com
&UploadMetadatas=[{"SourceURL":"https://example.aliyundoc.com/video01.mp4","Title":"urlUploadTest"}]
&UserData={"MessageCallback":{"CallbackURL":"http://example.aliyundoc.com"},"Extend":{"localId":"xxx","test":"www"}}
&AppId=app-****
&WorkflowId=e1e243b42548248197d6f74f9****
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<UploadMediaByURLResponse>
    <RequestId>25818875-5F78-4AF6-D7393642CA58****</RequestId>
    <UploadJobs>
        <SourceURL>http://****.mp4</SourceURL>
        <JobId>ad90a501b1b94fb72374ad005046****</JobId>
    </UploadJobs>
</UploadMediaByURLResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "25818875-5F78-4AF6-D7393642CA58****",
  "UploadJobs" : [ {
    "SourceURL" : "http://****.mp4",
    "JobId" : "ad90a501b1b94fb72374ad005046****"
  } ]
}

Error codes

For a list of error codes, visit the API Error Center.

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.

SDK examples

We recommend that you use a server SDK to call this operation. For more information about the sample code that is used to call this operation in various languages, see the following topics: