校验镜像文件
此接口用于通过镜像文件 hash 来校验文件是否为镜像文件以及文件片段是否上传完成。
接口描述
通信协议:HTTP
URL:POST /api/v1/image/hash/check
传参方式:body
请求参数
字段名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
imageHash | string | 是 | 镜像文件 hash |
chunkIndexArray | array | 是 | 文件片段数组 |
imageSize | int | 是 | 镜像大小,单位为 Byte |
响应参数
字段名 | 类型 | 说明 |
---|---|---|
imageId | string | 镜像 ID,不存在则返回 null |
uploadId | string | 上传任务 ID,不存在则返回 null |
imageHashExist | boolean | 本地是否存在该文件,如果存在则返回 true,否则返回 false |
isImage | isImage | 校验是否为镜像文件 |
chunkIndexArray | chunkIndexArray[ ] | 校验文件片段是否已上传完成 |
isImage
字段名 | 类型 | 说明 |
---|---|---|
result | boolean | 校验结果。true 表示为镜像文件;false 表示非镜像文件 |
detail | string | 当 result 为 false 时,返回非镜像文件的原因 |
chunkIndexArray
字段名 | 类型 | 说明 |
---|---|---|
index | int | 文件片段的索引 |
isExist | boolean | 文件片段是否已上传完成 |
请求示例
curl --location --request POST 'http://localhost:3001/api/v1/image/hash/check' \
--header 'Content-Type: application/json' \
--data-raw '
{
"imageHash":"5c9b626e46786aabe7257ef7c7e038400d70b622",
"chunkIndexArray":[1,2],
"imageSize": 7340032
}'
响应示例
{
"status": 200,
"message": "success",
"fieldErrors": null,
"data": {
"imageId": null,
"uploadId": null,
"isImage": {
"result": true,
"detail": null
},
"imageHashExist": false,
"chunkIndexArray": [
{
"index": 1,
"isExist": true
},
{
"index": 2,
"isExist": false
}
]
}
}
错误码
具体请参见 错误码说明。