上传镜像

更新时间:
2025-01-14

上传镜像

此接口用于上传镜像至本地仓库。

接口描述

通信协议:HTTP

URL:POST /api/v1/image

传参方式:body、headers

请求参数

字段名 类型 是否必填 说明 字段位置
fileapplication/octet-stream镜像文件片段body
descriptionstring文件描述信息headers
totalint镜像文件分片个数
indexint当前上传片段索引,从 1 开始
imageHashstring完整的镜像文件 hash。注意:非当前镜像片段 hash
totalSizeint完整镜像文件总大小,单位为 Byte
bufferSizeint当前镜像片段大小,单位为 Byte
offsetint切片大小,单位为 Byte

响应参数

字段名 类型 说明
uploadIdstring上传任务 ID

请求示例

var axios = require('axios');
var data = '<file contents here>';

var config = {
  method: 'post',
  url: 'http://localhost:3001/api/v1/image',
  headers: { 
    'description': 'redis', 
    'total': '20', 
    'index': '5', 
    'imageHash': '6a59f1cbb8d28ac484176d52c473494859a512ddba3ea62a547258cf16c9b3ae', 
    'totalSize': '104857600', 
    'bufferSize': '5242880', 
    'offset': '5242880', 
    'Content-Type': 'application/octet-stream'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

响应示例

{
  "status": 200,
  "message": "success",
  "fieldErrors": null,
  "data": {
    "uploadId": "e6crf87a4-a7cc-4857-8s40-95455b85ssx1"
  }
}

错误码

具体请参见 错误码说明

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