Documentation
SuperBoard_backup Super Board (Full version)
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Super Board (Full version)
  • Server API V2
  • Callback of the transcoding status

Callback of the file transcoding status

Last updated:2022-12-21 17:44

Description

If you require notification of successful file transcoding, contact ZEGOCLOUD Technical Support to configure a callback URL. Then, the file transcoding server will send a request to the callback URL in POST mode.

Callback description

  • Request method: POST/JSON
  • Request endpoint: Contact ZEGOCLOUD Technical Support to configure the endpoint.
  • Protocol: HTTPS

Request parameters

Parameter Type Description
appid
Number
App ID.
event
String
Callback event. The return value is cvt_finish.
nonce
String
String of random digits.
signature
String
Verification string. For details, see Verification description.
timestamp
Number
Current time of the server (Unix timestamp).
data
Object
Response object.
For details, see Data member list.

The following table lists data members.

Parameter Type Description
file_id
String
File ID returned after successful transcoding.
task_id
String
File transcoding task ID.
status
Number
File transcoding status. For details, see the following table of status description.

The following table lists the values of Status.

Status code Description
16 Transcoding succeeded.
32 Transcoding failed.
64 Transcoding task canceled.
128 Password-protected file.
256 The file is too large.
512 The Excel file contains too many sheets.
1024 The file is empty. For example, the PowerPoint file contains no slide.
2048 The transcoding server failed to open the file.
4096 The target file type is not supported.
8192 The source file is read-only.
16384

The transcoding server failed to download the source file. The possible causes are as follows:

  • Unable to download the file from the source file URL in the request parameters.
  • The file hash value in the request parameters is not a 32-bit MD5 hash value.
  • The file hash value in the request parameters does not match the hash value obtained from file-based calculation.
32768 Elements that cannot be processed by transcoding tools detected in the source file, such as ink marks and graffiti. Remove the elements and transcode the file again.
32769 The file format of the Word, Excel, or PowerPoint file is invalid. Ensure that the source file can be opened by Office before transcoding the file.

Sample data

{
    "appid": 123,
    "data": {
        "file_id": "ZYV-AFTrF6qnfFGW",
        "status": 16,
        "task_id": "9Y74yTsVd7e825-N"
    },
    "event": "cvt_finish",
    "nonce": "6990248315071153368",
    "signature": "1bb4db39726ee7f64c20ac0a71a730655b98ae2c",
    "timestamp": 1627544014
}

Verification description

To improve data security, the developer performs local signature calculation after receiving the callback from the ZEGO server and compares obtained signature with the file signature to determine whether the request is valid.

Encryption and verification

The encryption and verification flows are as follows:

The following table lists the parameters.

Parameter Description
callbacksecret Verification key on the server. The verification key is generated when a project is registered on the ZEGOCLLOUD console, and you can select Console > Project Configuration > Server-End API Key to view the key.
timestamp Unix timestamp.
nonce Random number.

Sample code

Refer to the following sample code for how to generate and verify the callback request signature.

  • Sample code in PHP
// Obtain signature, timestamp, and nonce from request parameters.
$signature = $_POST["signature"];
$timestamp = $_POST["timestamp"];
$nonce = $_POST["nonce"];

$secret = callbacksecret;// Callback secret obtained from the background.
$tmpArr = array($secret, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );

if( $tmpStr == $signature ){
    return true;
} else {
    return false;
}
  • Sample code in Java
// Obtain signature, timestamp, and nonce from request parameters.
String signature = request.getParameter("signature");
long timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");

// Callback secret obtained from the background.
String secret = callbacksecret;

String[] tempArr = {secret, ""+timestamp, nonce};
Arrays.sort(tempArr);

String tmpStr = "";
for (int i = 0; i < tempArr.length; i++) {
    tmpStr += tempArr[i];
}
tmpStr = org.apache.commons.codec.digest.DigestUtils.sha1Hex(tmpStr);

return tmpStr.equals(signature);

Sample output

$timestamp = 1470820198;
$nonce = 123412;
$secret = 'secret';

The original string to be encrypted after sequencing and splicing is 1234121470820198secret.
The encrypted result is 5bd59fd62953a8059fb7eaba95720f66d19e4517.

Return response

If the HTTP status code is 2XX (for example, 200)" is returned, the callback succeeded. Otherwise, the callback failed.

Callback retry policy

If the ZEGOCLOUD server receives no response, a callback will be initiated again after 15 seconds. Callback can be retried at most twice.

Page Directory
  • Free trial
  • 提交工单
    咨询集成、功能及报价等问题
    电话咨询
    400 1006 604
    Get Consulting
    Scan Wechat QR code