77 lines
2.0 KiB
Plaintext
77 lines
2.0 KiB
Plaintext
syntax = "v1"
|
|
|
|
info (
|
|
title: "File API"
|
|
desc: "API for ppanel file upload"
|
|
author: "Codex"
|
|
email: "codex@openai.com"
|
|
version: "0.0.1"
|
|
)
|
|
|
|
import "../types.api"
|
|
|
|
type (
|
|
FileUploadRequest {
|
|
BizType string `form:"biz_type" validate:"required"`
|
|
}
|
|
|
|
FileUploadResponse {
|
|
FileId string `json:"file_id"`
|
|
FileName string `json:"file_name"`
|
|
ObjectKey string `json:"object_key"`
|
|
Size int64 `json:"size"`
|
|
ContentType string `json:"content_type"`
|
|
Etag string `json:"etag"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
FileUploadInitRequest {
|
|
BizType string `json:"biz_type" validate:"required"`
|
|
FileName string `json:"file_name" validate:"required"`
|
|
ContentType string `json:"content_type" validate:"required"`
|
|
Size int64 `json:"size" validate:"required"`
|
|
Sha256 string `json:"sha256"`
|
|
}
|
|
|
|
FileUploadInitResponse {
|
|
FileId string `json:"file_id"`
|
|
ObjectKey string `json:"object_key"`
|
|
UploadURL string `json:"upload_url"`
|
|
Method string `json:"method"`
|
|
Headers map[string]string `json:"headers"`
|
|
ExpiredAt int64 `json:"expired_at"`
|
|
}
|
|
|
|
FileUploadCompleteRequest {
|
|
FileId string `json:"file_id" validate:"required"`
|
|
}
|
|
|
|
FileUploadCompleteResponse {
|
|
FileId string `json:"file_id"`
|
|
ObjectKey string `json:"object_key"`
|
|
Size int64 `json:"size"`
|
|
ContentType string `json:"content_type"`
|
|
Etag string `json:"etag"`
|
|
Status string `json:"status"`
|
|
}
|
|
)
|
|
|
|
@server (
|
|
prefix: v1/public/file
|
|
group: public/file
|
|
middleware: AuthMiddleware,DeviceMiddleware
|
|
)
|
|
service ppanel {
|
|
@doc "Upload file to RustFS"
|
|
@handler FileUpload
|
|
post /upload (FileUploadRequest) returns (FileUploadResponse)
|
|
|
|
@doc "Init file upload"
|
|
@handler FileUploadInit
|
|
post /upload/init (FileUploadInitRequest) returns (FileUploadInitResponse)
|
|
|
|
@doc "Complete file upload"
|
|
@handler FileUploadComplete
|
|
post /upload/complete (FileUploadCompleteRequest) returns (FileUploadCompleteResponse)
|
|
}
|