feat(storage): 实现本地存储功能,包括文件上传和下载接口

This commit is contained in:
2025-12-30 17:14:03 +08:00
parent 452cdc3f4f
commit b969218208
10 changed files with 291 additions and 27 deletions

View File

@@ -28,6 +28,7 @@ type Routes struct {
common *Common
content *Content
creator *Creator
storage *Storage
tenant *Tenant
transaction *Transaction
user *User
@@ -168,6 +169,21 @@ func (r *Routes) Register(router fiber.Router) {
r.creator.UpdateSettings,
Body[dto.Settings]("form"),
))
// Register routes for controller: Storage
r.log.Debugf("Registering route: Get /v1/storage/:key -> storage.Download")
router.Get("/v1/storage/:key"[len(r.Path()):], Func3(
r.storage.Download,
PathParam[string]("key"),
QueryParam[string]("expires"),
QueryParam[string]("sign"),
))
r.log.Debugf("Registering route: Put /v1/storage/:key -> storage.Upload")
router.Put("/v1/storage/:key"[len(r.Path()):], DataFunc3(
r.storage.Upload,
PathParam[string]("key"),
QueryParam[string]("expires"),
QueryParam[string]("sign"),
))
// Register routes for controller: Tenant
r.log.Debugf("Registering route: Delete /v1/tenants/:id/follow -> tenant.Unfollow")
router.Delete("/v1/tenants/:id/follow"[len(r.Path()):], Func1(