Files
tyc-server-v2/app/main/api/desc/front/upload.api
2026-02-12 15:16:54 +08:00

40 lines
1.1 KiB
Plaintext
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.

syntax = "v1"
info (
title: "上传"
desc: "图片上传,用于行驶证等需 URL 的接口"
version: "v1"
)
type (
UploadImageReq {
ImageBase64 string `json:"image_base64" validate:"required"` // 图片 base64不含 data URL 前缀)
}
UploadImageResp {
Url string `json:"url"` // 可公网访问的图片 URL
}
ServeUploadedFileReq {
FileName string `path:"fileName"` // 文件名,如 uuid.jpg
}
// 实际由 Handler 根据 FilePath/ContentType 写文件流,不返回 JSON
ServeUploadedFileResp {
FilePath string `json:"-"` // 内部:本地文件路径
ContentType string `json:"-"` // 内部Content-Type
}
)
@server (
prefix: api/v1
group: upload
)
service main {
@doc "上传图片,返回可访问 URL如行驶证限制 3MB"
@handler UploadImage
post /upload/image (UploadImageReq) returns (UploadImageResp)
@doc "访问已上传文件(供第三方或前端通过返回的 URL 拉取)"
@handler ServeUploadedFile
get /upload/file/:fileName (ServeUploadedFileReq) returns (ServeUploadedFileResp)
}