package v1 import ( "mime/multipart" "quyun/v2/app/http/v1/dto" "quyun/v2/app/services" "quyun/v2/database/models" "github.com/gofiber/fiber/v3" ) // @provider type Common struct{} // @Router /v1/upload [post] // @Summary Upload file // @Description Upload file // @Tags Common // @Accept multipart/form-data // @Produce json // @Param file formData file true "File" // @Param form formData dto.UploadForm true "Upload form" // @Success 200 {object} dto.UploadResult // @Bind user local key(__ctx_user) // @Bind file file // @Bind form body func (c *Common) Upload( ctx fiber.Ctx, user *models.User, file *multipart.FileHeader, form *dto.UploadForm, ) (*dto.UploadResult, error) { val := "" if form != nil { val = form.Type } return services.Common.Upload(ctx, user.ID, file, val) } // Get options (enums) // // @Router /v1/common/options [get] // @Summary Get options // @Description Get global options (enums) // @Tags Common // @Accept json // @Produce json // @Success 200 {object} dto.OptionsResponse func (c *Common) GetOptions(ctx fiber.Ctx) (*dto.OptionsResponse, error) { return services.Common.Options(ctx) } // Check file hash for deduplication // // @Router /v1/upload/check [get] // @Summary Check hash // @Description Check if file hash exists // @Tags Common // @Accept json // @Produce json // @Param hash query string true "File Hash" // @Success 200 {object} dto.UploadResult // @Bind user local key(__ctx_user) // @Bind hash query func (c *Common) CheckHash(ctx fiber.Ctx, user *models.User, hash string) (*dto.UploadResult, error) { return services.Common.CheckHash(ctx, user.ID, hash) }