file_system/docs/swagger.json
2025-12-18 09:34:49 +08:00

623 lines
21 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"swagger": "2.0",
"info": {
"description": "RustFS 文件存储系统 API支持分片上传、文件预览、分页查询等高级功能。",
"title": "RustFS File System API",
"contact": {},
"version": "1.1"
},
"host": "localhost:8080",
"basePath": "/",
"paths": {
"/buckets": {
"get": {
"description": "列出所有可用的 S3 存储桶",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"存储桶管理"
],
"summary": "获取存储桶列表",
"responses": {
"200": {
"description": "存储桶列表",
"schema": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"500": {
"description": "服务器内部错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"post": {
"description": "创建一个新的 S3 存储桶",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"存储桶管理"
],
"summary": "创建存储桶",
"parameters": [
{
"description": "创建存储桶请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CreateBucketRequest"
}
}
],
"responses": {
"200": {
"description": "创建成功消息",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "参数错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "服务器内部错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/files/download": {
"get": {
"description": "从指定的存储桶下载文件",
"consumes": [
"application/json"
],
"produces": [
"application/octet-stream"
],
"tags": [
"文件操作"
],
"summary": "下载文件",
"parameters": [
{
"type": "string",
"description": "存储桶名称",
"name": "bucket_name",
"in": "query",
"required": true
},
{
"type": "string",
"description": "对象键(文件名)",
"name": "object_key",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "文件流",
"schema": {
"type": "file"
}
},
"400": {
"description": "参数错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "服务器内部错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/files/list": {
"get": {
"description": "分页查询存储桶中的文件",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"文件操作"
],
"summary": "文件列表 (分页)",
"parameters": [
{
"type": "string",
"description": "存储桶名称",
"name": "bucket_name",
"in": "query",
"required": true
},
{
"type": "string",
"description": "文件名前缀筛选",
"name": "prefix",
"in": "query"
},
{
"type": "integer",
"description": "每页数量",
"name": "max_keys",
"in": "query"
},
{
"type": "string",
"description": "分页Token",
"name": "token",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/repository.ListFilesResult"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/files/multipart/complete": {
"post": {
"description": "合并所有分片完成上传",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"大文件上传"
],
"summary": "完成分片上传",
"parameters": [
{
"description": "请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CompleteMultipartRequest"
}
}
],
"responses": {
"200": {
"description": "返回文件位置",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/files/multipart/init": {
"post": {
"description": "开始一个新的大文件分片上传任务",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"大文件上传"
],
"summary": "初始化分片上传",
"parameters": [
{
"description": "请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.InitMultipartRequest"
}
}
],
"responses": {
"200": {
"description": "返回 upload_id",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/files/multipart/part": {
"put": {
"description": "上传单个文件分片",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"大文件上传"
],
"summary": "上传分片",
"parameters": [
{
"type": "string",
"description": "存储桶名称",
"name": "bucket_name",
"in": "formData",
"required": true
},
{
"type": "string",
"description": "对象键",
"name": "object_key",
"in": "formData",
"required": true
},
{
"type": "string",
"description": "上传ID",
"name": "upload_id",
"in": "formData",
"required": true
},
{
"type": "integer",
"description": "分片序号 (从1开始)",
"name": "part_number",
"in": "formData",
"required": true
},
{
"type": "file",
"description": "分片文件数据",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "返回 ETag",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/files/preview": {
"get": {
"description": "生成文件的临时预览链接 (24小时有效)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"文件操作"
],
"summary": "获取预览链接",
"parameters": [
{
"type": "string",
"description": "存储桶名称",
"name": "bucket_name",
"in": "query",
"required": true
},
{
"type": "string",
"description": "对象键",
"name": "object_key",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/files/upload": {
"post": {
"description": "上传小文件到指定的存储桶",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"文件操作"
],
"summary": "上传文件 (简单上传)",
"parameters": [
{
"type": "string",
"description": "存储桶名称",
"name": "bucket_name",
"in": "formData",
"required": true
},
{
"type": "file",
"description": "要上传的文件",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "上传成功消息",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"400": {
"description": "参数错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "服务器内部错误",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {
"common.Part": {
"type": "object",
"properties": {
"etag": {
"type": "string"
},
"partNumber": {
"type": "integer"
}
}
},
"repository.FileInfo": {
"type": "object",
"properties": {
"etag": {
"type": "string"
},
"key": {
"type": "string"
},
"lastModified": {
"type": "string"
},
"size": {
"type": "integer"
}
}
},
"repository.ListFilesResult": {
"type": "object",
"properties": {
"files": {
"type": "array",
"items": {
"$ref": "#/definitions/repository.FileInfo"
}
},
"nextContinuationToken": {
"type": "string"
}
}
},
"requests.CompleteMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
},
"parts": {
"type": "array",
"items": {
"$ref": "#/definitions/common.Part"
}
},
"upload_id": {
"type": "string"
}
}
},
"requests.CreateBucketRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
}
}
},
"requests.InitMultipartRequest": {
"type": "object",
"properties": {
"bucket_name": {
"type": "string"
},
"object_key": {
"type": "string"
}
}
}
}
}