Upload Media Upload

Update time: 2022/06/14 10:04:57

This topic describes how to call APIs to upload media files, trigger callbacks, and run the sample code. The API used to resume uploads is also included. In addition to server-side APIs, you can also log on to the CommsEase console or integrate the upload SDK to upload media files.

Upload media assets

The API is used to upload media assets and get xNosToken (the upload credential), bucket (the bucket name of storage object), and object (the unique object name).

URL

POST https://vcloud.163.com/app/vod/upload/init

Request parameters

Parameter Type Required Description
originFileName String Yes The original name of the uploaded file with the file extension.
userFileName String Optional The name of the uploaded file renamed by the user.
typeId Int Optional The type ID of the video file. The default type is applied if unspecified.
presetId Int Optional The ID of the transcoding template used to transcode the video file. The default template is used if unspecified. The video file is not transcoded with the default template.
uploadCallbackUrl String Optional The URL of the callback that sends notifications to clients after the upload is complete. The callback sends notifications over standard HTTP.
callbackUrl String Optional The URL of the callback that sends notifications to clients after transcoding is complete. The callback sends notifications over standard HTTP.
description String Optional The description of the uploaded video.
watermarkId Int Optional The watermark ID. No watermark is added if unspecified. If you specify a watermark ID,
you must upload the watermark image that is flagged with the ID and configure the parameters. The presetId parameter is also required and the default template is not used.
userDefInfo String Optional User-defined information, which is returned in the notification sent by the callback. The information can contains up to 256 characters in length.
transOffset Int Optional The starting position of the cropped video for video transcoding processing. Unit: seconds.
transDuration Int Optional The duration consumed to process the cropped video. Unit: seconds.

Response parameters

Parameter Type Description
code Int The status code.
accessKeyId String AWS STS keyId.
secretAccessKey String AWS STS accessKey.
sessionToken String AWS STS token.
region String aws s3 region.
bucket String The bucket name for the uploaded file.
object String The name of the object that stores the uploaded file.
msg String The error message.

Response status codes

Status code Description
200 The operation was successful.
400 The request message format is invalid. The message structure is invalid, or the message is incomplete.
700 An internal server error occurred. Try again later or send the complete error message to customer service for help.
710 Authorization failed. See the authentication section in the specified API reference.
720 Access failed. The account has an insufficient balance.
721 The service has not been activated. You can activate the service on the product page.
722 The application to activate the service is under review. You can contact customer service for help.
723 The number of requests exceeds the upper limit.

Example

curl request example

	curl -X POST -H "Content-Type: application/json;charset=utf-8" -H "AppKey: 027338bf05cc4a65b5d98bc9d6af80b3" -H "Nonce: 1" -H "CurTime: 1465723418" -H "CheckSum: 61bbfd88c51028a2a28b3628584e65a2abe7ae13" -d'{"originFileName":"love.mp4","userFileName":"for_love.mp4","typeId":20,"presetId":20,"description":"for love","wartermarkId":20}' https://vcloud.163.com/app/vod/upload/init

Sample response

    "Content-Type": "application/json; charset=utf-8"
    {
    	"code" : 200,
    	"ret" : {
    		"xNosToken" : "UPLOAD ab1856bb39044591939d7b94e1b8e5ee:n5VKrOLVFkLM7JIBDaCyPjzVKswqfxBZak2U2fXh0xM=:eyJCdWNrZXQiOiJ2b2RrMzJ5d3hkZiIsIk9iamVjdCI6ImEzM2U1MmQ3LTUxZGMtNDZhNS1iMTFlLWFiNmMyMmJiOTk2ZC5KUEciLCJFeHBpcmVzIjoxNDY5NTg3NTc5LCJDYWxsYmFja1VybCI6Imh0dHA6Ly8xMDYuMi40NC4yNDgveGhyL3ZvZC9ub3MvY2FsbGJhY2siLCJDYWxsYmFja0JvZHkiOiJmaWxlTmFtZT10ZXN0LkpQRyZvYmplY3ROYW1lPWEzM2U1MmQ3LTUxZGMtNDZhNS1iMTFlLWFiNmMyMmJiOTk2ZC5KUEcmJChPYmplY3RTaXplKSZ1aWQ9MjQxMzMmdHlwZUlkPTAmcHJlc2V0SWQ9MCZ3YXRlcm1hcmtJZHM9bnVsbCZkZXNjcmlwdGlvbj1udWxsJnZpZGVvQ2FsbGJhY2s9bnVsbCYkKEFWaW5mby5WaWRlby5EdXJhdGlvbikmJChBVmluZm8uVmlkZW8uSGVpZ2h0KSYkKEFWaW5mby5WaWRlby5XaWR0aCkmMCYwJjAmbnVsbCZ1cGxvYWRTdGFydD0xNDY2OTk1NTc5NjU4In0=",
    		"bucket" : "vodk32ywxdf",
    		"object" : "d37906a7-0119-4dd9-820d-4c66a71952ad.mp4"
    	}
    }

Query the ID of a specified media asset

The API is used to query the ID of a specified media asset after the video or watermark is uploaded.

URL

POST https://vcloud.163.com/app/vod/video/query

Request parameters

Parameter Type Required Description
objectNames List Yes The object names of uploaded files.

Response parameters

Parameter Type Description
code Int The status code.
list List The list of object names and corresponding IDs of video files.
list.vid Long The ID of a video file.
list.imgId Int The ID of a watermark image.
list.objectName String The name of the object that stores the uploaded file.
msg String The error message.

Response status codes

Status code Description
200 The operation was successful.
400 The request message format is invalid. The message structure is invalid, or the message is incomplete.
700 An internal server error occurred. Try again later or send the complete error message to customer service for help.
710 Authorization failed. See the authentication section in the specified API reference.
720 Access failed. The account has an insufficient balance.
721 The service has not been activated. You can activate the service on the product page.
722 The application to activate the service is under review. You can contact customer service for help.
723 The number of requests exceeds the upper limit.

Example

curl request example

curl -X POST -H "Content-Type: application/json;charset=utf-8" -H "AppKey: 027338bf05cc4a65b5d98bc9d6af80b3" -H "Nonce: 1" -H "CurTime: 1465723418" -H "CheckSum: 61bbfd88c51028a2a28b3628584e65a2abe7ae13" -d'{"objectNames":["33cf71b1-86ac-4555-a071-d70db07b9685.mp4"]}' https://vcloud.163.com/app/vod/video/query

Sample response

"Content-Type": "application/json; charset=utf-8"
{
	"code" : 200,
	"ret" : {
		list : [
			{
				"objectName" : "33cf71b1-86ac-4555-a071-d70db07b9685.mp4",
				"vid" : 1008
			}
		]
	}
}

Upload callback

The API is used to send the callback notification after the media asset is uploaded. For more information about how to configure the setting and manage the callbacks, see Callback Management.

Example

{
    "name":"snow.mp4",
    "origAddr":"http://vodk32ywxdf.vod.126.net/vodk32ywxdf/b3d259f4-a7bc-4119-ae24-60e0eb09216e.mp4",
    "type":"upload",
    "vid":1022,
    "fileSize": 111233,
    "user_defined":"userId=123456"
}

The parameters are contained in the body of the example response. You must use actual parameters for your purpose.

Response parameters

Parameter Type Description
type String The callback type. Set the value to upload.
vid Long The identifier of a video file.
fileSize Long The size of a video file in bytes.
name String The name of a video file specified for upload.
origAddr String The URL used to play back the video file.
warnning String The result of the detected video types. For example, the video type and the upload specification are inconsistent. MP4 and FLV videos are not suitable for slide-and-seek playback.
user_defined String The user-defined field value specified for upload.
Was this page helpful?
Yes
No
  • Upload media assets
  • URL
  • Request parameters
  • Response parameters
  • Response status codes
  • Example
  • curl request example
  • Sample response
  • Query the ID of a specified media asset
  • URL
  • Request parameters
  • Response parameters
  • Response status codes
  • Example
  • curl request example
  • Sample response
  • Upload callback
  • Example
  • Response parameters