package handlers import ( "context" "file-system/internal/domain/repository" "io" "time" "file-system/internal/common" ) // Queries & Commands type ListFilesQuery struct { BucketName string Prefix string MaxKeys int32 Token *string } type GetFilePreviewQuery struct { BucketName string ObjectKey string Expiry time.Duration } type InitMultipartCommand struct { BucketName string ObjectKey string } type UploadPartCommand struct { BucketName string ObjectKey string UploadId string PartNumber int32 Data io.Reader } type CompleteMultipartCommand struct { BucketName string ObjectKey string UploadId string Parts []common.Part } // Handlers type ListFilesHandler struct { Repo repository.FileRepository } func NewListFilesHandler(repo repository.FileRepository) *ListFilesHandler { return &ListFilesHandler{Repo: repo} } func (h *ListFilesHandler) Handle(ctx context.Context, q ListFilesQuery) (*repository.ListFilesResult, error) { return h.Repo.ListObjectsV2(ctx, q.BucketName, q.Prefix, q.MaxKeys, q.Token) } type GetFilePreviewHandler struct { Repo repository.FileRepository } func NewGetFilePreviewHandler(repo repository.FileRepository) *GetFilePreviewHandler { return &GetFilePreviewHandler{Repo: repo} } func (h *GetFilePreviewHandler) Handle(ctx context.Context, q GetFilePreviewQuery) (string, error) { return h.Repo.GeneratePresignedURL(ctx, q.BucketName, q.ObjectKey, q.Expiry) }