上传镜像
此接口用于上传镜像至本地仓库。
接口描述
通信协议:HTTP
URL:POST /api/v1/image
传参方式:body、headers
请求参数
字段名 | 类型 | 是否必填 | 说明 | 字段位置 |
---|---|---|---|---|
file | application/octet-stream | 是 | 镜像文件片段 | body |
description | string | 否 | 文件描述信息 | headers |
total | int | 是 | 镜像文件分片个数 | |
index | int | 是 | 当前上传片段索引,从 1 开始 | |
imageHash | string | 是 | 完整的镜像文件 hash。注意:非当前镜像片段 hash | |
totalSize | int | 是 | 完整镜像文件总大小,单位为 Byte | |
bufferSize | int | 是 | 当前镜像片段大小,单位为 Byte | |
offset | int | 是 | 切片大小,单位为 Byte |
响应参数
字段名 | 类型 | 说明 |
---|---|---|
uploadId | string | 上传任务 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"
}
}
错误码
具体请参见 错误码说明。