校验镜像文件

更新时间:
2025-01-14

校验镜像文件

此接口用于通过镜像文件 hash 来校验文件是否为镜像文件以及文件片段是否上传完成。

接口描述

通信协议:HTTP

URL:POST /api/v1/image/hash/check

传参方式:body

请求参数

字段名 类型 是否必填 说明
imageHashstring镜像文件 hash
chunkIndexArrayarray文件片段数组
imageSizeint镜像大小,单位为 Byte

响应参数

字段名 类型 说明
imageIdstring镜像 ID,不存在则返回 null
uploadIdstring上传任务 ID,不存在则返回 null
imageHashExistboolean本地是否存在该文件,如果存在则返回 true,否则返回 false
isImageisImage校验是否为镜像文件
chunkIndexArraychunkIndexArray[ ]校验文件片段是否已上传完成

isImage

字段名 类型 说明
resultboolean校验结果。true 表示为镜像文件;false 表示非镜像文件
detailstring当 result 为 false 时,返回非镜像文件的原因

chunkIndexArray

字段名 类型 说明
indexint文件片段的索引
isExistboolean文件片段是否已上传完成

请求示例

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
      }
    ]
  }
}

错误码

具体请参见 错误码说明

文档内容是否对您有所帮助?
有帮助
没帮助