Skip to content

Commit

Permalink
Merge pull request #531 from xxxxibo/main
Browse files Browse the repository at this point in the history
chore: add swagger doc for GetSuccessChunks
  • Loading branch information
bjwswang committed Jan 10, 2024
2 parents e8c1f92 + 50d6df2 commit 880c375
Show file tree
Hide file tree
Showing 4 changed files with 307 additions and 13 deletions.
109 changes: 109 additions & 0 deletions apiserver/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,84 @@ const docTemplate = `{
}
}
}
},
"/model/files/chunks": {
"get": {
"description": "Get success chunks of a file",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"MinioAPI"
],
"summary": "Get success chunks of a file",
"parameters": [
{
"type": "string",
"description": "MD5 value of the file",
"name": "md5",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Name of the file",
"name": "fileName",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Name of the bucket",
"name": "namespace",
"in": "header",
"required": true
},
{
"type": "string",
"description": "Path of the bucket",
"name": "bucketPath",
"in": "query",
"required": true
},
{
"type": "string",
"description": "ETag of the file",
"name": "etag",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/service.SuccessChunksResult"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {
Expand Down Expand Up @@ -518,6 +596,37 @@ const docTemplate = `{
"example": 0.34
}
}
},
"service.Chunk": {
"type": "object",
"properties": {
"etag": {
"type": "string"
},
"partNubmer": {
"type": "integer"
},
"size": {
"type": "integer"
}
}
},
"service.SuccessChunksResult": {
"type": "object",
"properties": {
"chunks": {
"type": "array",
"items": {
"$ref": "#/definitions/service.Chunk"
}
},
"done": {
"type": "boolean"
},
"uploadID": {
"type": "string"
}
}
}
}
}`
Expand Down
109 changes: 109 additions & 0 deletions apiserver/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,84 @@
}
}
}
},
"/model/files/chunks": {
"get": {
"description": "Get success chunks of a file",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"MinioAPI"
],
"summary": "Get success chunks of a file",
"parameters": [
{
"type": "string",
"description": "MD5 value of the file",
"name": "md5",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Name of the file",
"name": "fileName",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Name of the bucket",
"name": "namespace",
"in": "header",
"required": true
},
{
"type": "string",
"description": "Path of the bucket",
"name": "bucketPath",
"in": "query",
"required": true
},
{
"type": "string",
"description": "ETag of the file",
"name": "etag",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/service.SuccessChunksResult"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {
Expand Down Expand Up @@ -507,6 +585,37 @@
"example": 0.34
}
}
},
"service.Chunk": {
"type": "object",
"properties": {
"etag": {
"type": "string"
},
"partNubmer": {
"type": "integer"
},
"size": {
"type": "integer"
}
}
},
"service.SuccessChunksResult": {
"type": "object",
"properties": {
"chunks": {
"type": "array",
"items": {
"$ref": "#/definitions/service.Chunk"
}
},
"done": {
"type": "boolean"
},
"uploadID": {
"type": "string"
}
}
}
}
}
73 changes: 73 additions & 0 deletions apiserver/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,26 @@ definitions:
example: 0.34
type: number
type: object
service.Chunk:
properties:
etag:
type: string
partNubmer:
type: integer
size:
type: integer
type: object
service.SuccessChunksResult:
properties:
chunks:
items:
$ref: '#/definitions/service.Chunk'
type: array
done:
type: boolean
uploadID:
type: string
type: object
info:
contact: {}
paths:
Expand Down Expand Up @@ -354,4 +374,57 @@ paths:
summary: get one message references
tags:
- application
/model/files/chunks:
get:
consumes:
- application/json
description: Get success chunks of a file
parameters:
- description: MD5 value of the file
in: query
name: md5
required: true
type: string
- description: Name of the file
in: query
name: fileName
required: true
type: string
- description: Name of the bucket
in: header
name: namespace
required: true
type: string
- description: Path of the bucket
in: query
name: bucketPath
required: true
type: string
- description: ETag of the file
in: query
name: etag
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/service.SuccessChunksResult'
"400":
description: Bad Request
schema:
additionalProperties:
type: string
type: object
"500":
description: Internal Server Error
schema:
additionalProperties:
type: string
type: object
summary: Get success chunks of a file
tags:
- MinioAPI
swagger: "2.0"
29 changes: 16 additions & 13 deletions apiserver/service/minio_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,22 @@ const (
namespaceHeader = "namespace"
)

/*
GetSuccessChunks
There are three different scenarios:
1. If the file exists, the function will return done=true and will not provide an uploadid.
In this case, no further action is required for uploading because the file is already present.
2. If the file does not exist, the function will return done=false.
In this case, you need to request a new uploadid to initiate the upload process.
3. If the upload is in progress, the function will return done=false, uploadid (e.g., uploadid=xx) and chunks={partNumber, etag}.
In this case, you can utilize the provided uploadid to continue requesting the upload URL and proceed with the file upload process.
*/
// @BasePath /bff
// @Summary Get success chunks of a file
// @Schemes
// @Description Get success chunks of a file
// @Tags MinioAPI
// @Accept json
// @Produce json
// @Param md5 query string true "MD5 value of the file"
// @Param fileName query string true "Name of the file"
// @Param namespace header string true "Name of the bucket"
// @Param bucketPath query string true "Path of the bucket"
// @Param etag query string true "ETag of the file"
// @Success 200 {object} SuccessChunksResult
// @Failure 400 {object} map[string]string
// @Failure 500 {object} map[string]string
// @Router /model/files/chunks [get]
func (m *minioAPI) GetSuccessChunks(ctx *gin.Context) {
fildMD5 := ctx.Query(md5Query)
if fildMD5 == "" {
Expand Down

0 comments on commit 880c375

Please sign in to comment.