6.5 KiB
6.5 KiB
JCS-pub API
1 桶相关
1.1 创建桶
请求 | ||
---|---|---|
POST | application/json | /v1/bucket/create |
Query | 无 | |
Body |
{ "userID": 1, "name": "bkt1" //桶名 } |
|
响应示例 | ||
{ "code": "OK", "message": "", "data": { "bucket": { "bucketID": 1, // 桶ID "name": "bkt1" // 桶名 } } } |
1.2 根据名字查询桶
1.3 查询所有桶
1.4 删除桶
2 包相关
2.1 创建包
2.2 根据桶名和包名查询包
2.3 获取桶里所有的包
2.4 删除包
3 对象相关
3.1 批量上传对象
请求 | ||
---|---|---|
POST | multipart/form-data; boundary=xxxxxxx | /v1/object/upload |
Query | 无 | |
Body |
被boundary分隔的多个part,第一个part的name必须是info,格式如下: {
"packageID": 1, // PackageID,使用从创建Package接口返回的ID
"affinity": 1 // 文件优先上传到哪个存储空间,可以不填。
}
之后的每一个part都是一个文件,name为files,filename为文件路径,需要进行URL编码。 一个例子: POST /object/upload HTTP/1.1 User-Agent: PostmanRuntime/7.29.0 Accept: */* Postman-Token: c12fa8b5-d902-46f3-b104-028effa0d531 Host: localhost:7890 Accept-Encoding: gzip, deflate, br Connection: keep-alive Content-Type: multipart/form-data; boundary=-----------------------------818270992847011232305151 Content-Length: 1649 -----------------------------818270992847011232305151 Content-Disposition: form-data; name="info" { "userID": 1, "packageID": 1 } -----------------------------818270992847011232305151 Content-Disposition: form-data; name="files"; filename="test.txt" Content-Type: text/plain testdata -----------------------------818270992847011232305151 Content-Disposition: form-data; name="files"; filename="a%2Fb%2Ftest2.txt" testdata2 -----------------------------818270992847011232305151-- |
|
响应示例 | ||
{ "code": "OK", "message": "", "data": { "uploadeds": [ { "objectID": 7, "packageID": 1, "path": "test.txt", "size": "123456", "fileHash": "xxxxxxxxxx", "redundancy": { "type": "none" }, "createTime": "2024-11-05T11:06:28+08:00", "updateTime": "2025-01-10T09:15:39.4452196+08:00" }, { "objectID": 8, "packageID": 1, "path": "a/b/test2.txt", "size": "123456", "fileHash": "xxxxxxxxxx", "redundancy": { "type": "none" }, "createTime": "2024-11-05T11:06:28+08:00", "updateTime": "2025-01-10T09:15:39.4452196+08:00" } ] } } |
3.2 下载对象
请求 | ||
---|---|---|
GET | application/json | /v1/bucket/download |
Query |
- objectID:int64 - offset:int64,偏移量 - length:int64,读取长度。不存在则读取整个对象 |
|
Body | 无 | |
响应示例 | ||
如果请求成功,那么Content-Type将会是application/octet-stream,响应体就是文件数据。 如果失败,那么Content-Type将会是application/json,响应体格式如下: { "code": "OperationFailed", "message": "xxxxxxxx", "data": null } |