Files
cloudnest/internal/interface/http/routes/file_routes.go
T

53 lines
1.6 KiB
Go

package routes
import (
"cloudnest/internal/interface/http/handler"
"github.com/gin-gonic/gin"
)
// RegisterFileRoutes registers file management routes.
// RegisterFileRoutes 注册文件管理路由。
//
// Parameters:
// - r: The router group to register routes on.
// - h: The file handler.
//
// Routes:
// - POST /upload: Upload a file.
// - GET /: List all files for the authenticated user.
// - GET /download/:name: Get a pre-signed download URL.
// - DELETE /:name: Delete a file.
//
// Note:
// - These routes require JWT authentication.
//
// 参数:
// - r: 要注册路由的路由器组。
// - h: 文件处理器。
//
// 路由:
// - POST /upload: 上传文件。
// - GET /: 获取认证用户的所有文件列表。
// - GET /download/:name: 获取预签名下载 URL。
// - DELETE /:name: 删除文件。
//
// 注意:
// - 这些路由需要 JWT 认证。
func RegisterFileRoutes(r *gin.RouterGroup, h *handler.FileHandler) {
r.POST("/upload", h.Upload)
r.GET("/upload/check", h.CheckUpload)
r.POST("/upload/chunk", h.UploadChunk)
r.POST("/upload/complete", h.CompleteUpload)
r.GET("/", h.List)
r.GET("/download/:name", h.Download)
r.GET("/content/:name", h.Content)
r.DELETE("/:name", h.Delete)
r.POST("/soft-delete/:name", h.SoftDelete)
r.POST("/favorite/:name", h.Favorite)
r.DELETE("/favorite/:name", h.Unfavorite)
r.GET("/favorites", h.ListFavorites)
r.GET("/recycle-bin", h.RecycleBin)
r.POST("/restore/:name", h.Restore)
r.DELETE("/recycle-bin/:name", h.DeleteFromRecycleBin)
r.GET("/preview/:name", h.Preview)
}