All Products
Search
Document Center

Intelligent Media Services:UploadMediaByURL

Last Updated:Nov 25, 2024

Uploads an audio or video file based on the URL of the source file. You can upload multiple media files at a time.

Operation description

  • If a callback is configured, you will receive an UploadByURLComplete event notification after the file is uploaded. You can query the upload status by calling the GetURLUploadInfos operation.
  • After a request is submitted, the upload job is queued as an asynchronous job in the cloud. You can query the status of the upload job based on information such as the URL and media asset ID that are returned in the event notification.
  • You can call this operation to upload media files that are not stored on a local server or device and must be uploaded by using URLs that are accessible over the Internet.
  • You can call this operation to upload media files only to ApsaraVideo VOD, but not to your own Object Storage Service (OSS) buckets. To upload a media file to an OSS bucket, pull the file to a local directory, use OSS SDK to upload the file to an OSS bucket, and then call the RegisterMediaInfo operation to register the file in the OSS bucket with the media asset library.
  • This operation is available only in the China (Shanghai), China (Beijing), and China (Shenzhen) regions.
  • You can call this operation to upload only audio and video files.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
ice:UploadMediaByURLcreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
UploadURLsstringNo

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 FileExtension in UploadMetadata.
    • If the URL contains a file name extension and FileExtension is also specified, the value of FileExtension prevails.
  • URL encoding is required. Separate multiple URLs with commas (,). You can specify a maximum of 20 URLs.

  • Special characters may cause upload failures. Therefore, you must encode URLs before you separate them with commas (,).

https://diffurl.mp4
AppIdstringNo

The application ID.

app-1000000
UserDatastringNo

The user data. The value must be a JSON string. You can configure settings such as message callbacks.

{"MessageCallback":{"CallbackURL":"http://example.aliyundoc.com"},"Extend":{"localId":"xxx","test":"www"}}
UploadTargetConfigstringNo

The destination storage address.

Set StorageType to oss.

Set StorageLocation to an address in ApsaraVideo VOD. You cannot set this field to an OSS URL.

{"StorageType":"oss","StorageLocation":"outin-***.oss-cn-shanghai.aliyuncs.com"}
MediaMetaDatastringNo

The metadata of the media file that you want to upload. The value must be a JSON string.

  • This parameter takes effect only if its value matches a URL that is specified in UploadURLs.
  • You must convert the JSON-formatted data, such as [UploadMetadata, UploadMetadata,…], into a JSON string.
  • For more information, see the "UploadMetadata" section of this topic.
[{"SourceURL":"https://example.aliyundoc.com/video01.mp4","Title":"urlUploadTest"}]
PostProcessConfigstringNo

The postprocessing configurations. You can specify this parameter if Type is set to video or audio.

Set ProcessType to Workflow.

{"ProcessType": "Workflow","ProcessID":"b72a06c6beeb4dcdb898feef067b1***"}
EntityIdstringNo

The entity ID. You can call the CreateEntity operation to create an entity and specify a dynamic metadata structure.

d67281da3c8743b8823ad12976187***

UploadMetadata

FieldTypeRequiredDescription
SourceURLStringYesThe URL of the source file that you want to upload.
TitleStringYesThe title of the media asset. The value can be up to 128 bytes in length. The value must be encoded in UTF-8.
FileSizeStringNoThe file size.
DescriptionStringNoThe description of the media asset. The value can be up to 1024 bytes in length. The value must be encoded in UTF-8.
CoverURLStringNoThe URL of the custom video thumbnail.
CateIdStringNoThe category ID.
TagsStringNoThe tags that you want to add to the media asset. 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 is encoded in UTF-8.
WorkflowIdStringNoThe workflow ID.
FileExtensionStringNoThe file name extension.
DynamicMetaDataStringNoThe dynamic metadata. Example: "{"Uploader": "xxx"}".
EntityIdStringNoThe entity ID.

Note* The values of fields, such as Title, Description, and Tags, in UploadMetadata cannot contain emojis.

  • If a callback is configured, you can receive an UploadByURLComplete event notification when the media file is uploaded. You can also receive the FileUploadComplete and StreamTranscodeComplete event notifications.

  • If you upload multiple media files at a time, an event notification is sent for each media file when the media file is uploaded.

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The request ID.

****83B7-7F87-4792-BFE9-63CD2137****
UploadJobsarray<object>

The information about upload jobs.

UploadJobobject

The details of the upload job.

JobIdstring

The ID of the upload job.

20ce1e05dba64576b96e9683879f0***
SourceURLstring

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

http://example****.mp4
MediaIdstring

The ID of the media asset.

f476988629f54a7b8a4ba90d1a6c7***

Examples

Sample success responses

JSONformat

{
  "RequestId": "****83B7-7F87-4792-BFE9-63CD2137****",
  "UploadJobs": [
    {
      "JobId": "20ce1e05dba64576b96e9683879f0***",
      "SourceURL": "http://example****.mp4\n",
      "MediaId": "f476988629f54a7b8a4ba90d1a6c7***"
    }
  ]
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history