package logic import ( "context" "spark-server/internal/module/upload/entity" "spark-server/internal/pkg/errs" "spark-server/internal/pkg/reqctx" "spark-server/internal/pkg/validate" ) // DownloadInput requests a short-lived GET URL for an already-uploaded object key. type DownloadInput struct { ObjectKey string `json:"object_key" validate:"required,max=512" label:"field.object_key" errmsg:"required:validate.upload.key_required;max:validate.upload.key_invalid"` } func (s *Service) CreateDownload(ctx context.Context, userID int64, in *DownloadInput) (*entity.Download, error) { if !s.ready() { return nil, errs.ErrAvailable } if userID <= 0 { return nil, errs.ErrUnauthorized } if in == nil { return nil, errs.ErrInvalidArgument } if err := validate.StructLang(reqctx.Lang(ctx), in); err != nil { return nil, err } if !s.allow(userID) { return nil, errs.ErrRateLimited } return s.issueGet(ctx, in.ObjectKey) }