通知说明

更新时间:2023-08-17 17:37:00

本章介绍上传文件预处理(如在上传凭证携带persistentOps指令)任务的通知说明。

通知安全机制

网宿云存储会在通知的请求头中,加入Authorization字段。
格式:

<Accesskey>:<Urlsafe_Base64_Encode(hmac_sha1(NotifyUrlWithOutQuery+"\n"+NotifyBody,SecretKey))>

注:

  1. NotifyBody为接收到的通知内容;
  2. 网宿云存储随机选取用户下的任一一组有效AK、SK生成鉴权头部Authorization的值。鉴权过程中,需记录所有AK、SK组,用其中一组正确匹配的密钥串进行头部鉴定。

通知数据说明

设置通知地址NotifyUrl后,该地址会获取到的一个经过URL安全的Base64编码json格式的NotifyBody信息,该信息即持久化处理结果。

注:接收预处理结果通知的地址,必须是公网URL地址,能正常响应HTTP/1.1 200 OK,若有空格等特殊字符,需要进行Url Encode编码。

格式:

{
    "id": "<id string>",
    "code": "<code int>",
    "desc": "<desc string>",
    "separate":"<separate int>",
    "inputkey":"<inputkey string>",
    "inputbucket":"<inputbucket string>" ,
    "inputfsize":"<inputfsize int>"
    "items": [
        {
            "cmd": "<cmd string>",
            "code": "<code string>",
            "costTime": "<costTime int>",
            "desc": "<desc string>",
            "error": "<error string>",
            "fsize": "<fsize int>",
            "hash": "<hash string>",
            "key": "<key string>",
            "url": "<url string>",
            "duration": "<duration double>",
            "bit_rate": "<bit_rate string>",
            "resolution": "<resolution string>",
            "detail": [
            {
                "fsize": "<fsize int>",
                "tssize": "<tssize int>",
                "hash": "<hash string>",
                "key": "<key string>",
                "url": "<url string>",
                "duration": "<duration double>",
                "bit_rate": "<bit_rate string>",
                "resolution": "<resolution string>"
             }]
        }]
}

说明:

字段名 类型 描述
id string 上传预处理或者触发持久化处理接口返回的persistentId
code int 通知进展状态码,1分开通知,有任务处理中,2分开通知,有任务处理失败,3通知成功
desc string 与状态码相应的详细描述
separate string 分开通知选项,0表示一次性通知,1表示分开通知
inputkey string 原始文件名
inputbucket string 原始文件空间
inputfsize number 原始文件大小
items array 每个操作的状态信息,如果处理请求包括多个操作,则items包含多条信息
cmd string 操作命令(ops)
code string 处理结果状态码,2处理失败,3处理成功
costTime int 转码花费的时间,非特殊场景默认是0
desc string 与状态码相应的详细描述
error string 如果处理失败,该字段列出具体原因
fsize number 处理后的文件大小
hash string 处理结果的hash
key string 处理结果的key
url string 资源的访问路径
duration double 转码输出的视频时长
bit_rate string 转码输出的视频码率
resolution string 转码输出的视频分辨率
detail array 输出文件为多个时,每一个数据文件的具体信息
fsize number 处理后的文件大小。若输出视频格式为m3u8格式时,这个字段表示m3u8文件的大小
tssize number 输出视频格式为m3u8格式时,表示ts的总大小;若输出视频格式非m3u8格式,则该字段为0
hash string 处理结果的hash
key string 处理结果的key
url string 资源的访问路径url
duration double 转码出的视频时长
bit_rate string 转码输出的视频码率
resolution string 转码输出的视频分辨率

范例:

{
    "id":"2c90802745ee87870145ef1430f90006",
    "code":3,
    "desc": "operate ["avthumb/flv"] is finish",
    "separate":0,
    "inputkey":"aaa.flv",
    "inputbucket":"chenqltesttwo",
    "inputfsize":20000,
    "items":[
        {
            "cmd":"avthumb/flv",
            "code":"3",
            "costTime": 0,
            "desc":"finish",
            "error":null,
            "fsize":20000,
            "hash":"FlWvHsc-CK6miygKCcLjCaQ5csNO",
            "key":"chenqltesttwo:aaa.flv",
            "url":"http://chenqltesttwo.com/aaa.flv",
            "duration": 198.083,
            "bit_rate": "1288025",
            "resolution": "1280X720",
            "detail": [
            {
                "fsize": 20000,
                "tssize":0,
                "hash": "FlWvHsc-CK6miygKCcLjCaQ5csNO",
                "key": "chenqltesttwo:aaa.flv",
                "url": "http://chenqltesttwo.com/aaa.flv",
                "duration": 198.083,
                "bit_rate": "1288025",
                "resolution": "1280X720",
            }]
        }]
    }
}
本篇文档内容对您是否有帮助?
有帮助
我要反馈
提交成功!非常感谢您的反馈,我们会继续努力做到更好!