backend/generate/api/file_storage.api

52 lines
1.9 KiB
Plaintext
Raw Permalink 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.

syntax = "v1"
// 圖片上傳請求(使用 base64
type UploadImgReq {
Authorization
Content string `json:"content" validate:"required"` // base64 編碼的圖片內容
}
// 影片上傳請求(使用 multipart/form-data 文件上傳)
// 注意:文件需要在 handler 中通過 r.FormFile("file") 獲取
type UploadVideoReq {
Authorization
}
// 統一的上傳響應
type UploadResp {
FileUrl string `json:"file_url"` // 文件訪問 URL
FileSize int64 `json:"file_size,optional"` // 文件大小bytes
MimeType string `json:"mime_type,optional"` // MIME 類型
}
@server(
group: fileStorage
prefix: /api/v1/fileStorage
schemes: https
timeout: 300s // 影片上傳可能需要更長時間
middleware: AuthMiddleware
)
service gateway {
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
/* @respdoc-403 (BaseResponse) // 無效的Token */
/* @respdoc-413 (BaseResponse) // 文件大小超過限制 */
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
@doc(
summary: "create - 上傳圖片檔案"
description: "上傳轉成 base64 過後的圖片,建議圖片大小不超過 10MB"
)
@handler UploadImgHandler
post /fileStorage/img/upload (UploadImgReq) returns (UploadResp)
/* @respdoc-400 (BaseResponse) // 輸入的參數錯誤 */
/* @respdoc-403 (BaseResponse) // 無效的Token */
/* @respdoc-413 (BaseResponse) // 文件大小超過限制 */
/* @respdoc-500 (BaseResponse) // 伺服器出錯 */
@doc(
summary: "create - 上傳影片檔案"
description: "使用 multipart/form-data 上傳影片檔案form field 名稱為 'file',注意:大檔案(>50MB建議使用分片上傳機制"
)
@handler UploadVideoHandler
post /fileStorage/video/upload (UploadVideoReq) returns (UploadResp)
}