[feature] migrate to monorepo
Some checks failed
Build Backend / Build Docker Image (push) Successful in 3m33s
Test Backend / test (push) Failing after 31s

This commit is contained in:
CDN 2025-02-21 00:49:20 +08:00
commit 05ddc1f783
Signed by: CDN
GPG key ID: 0C656827F9F80080
267 changed files with 75165 additions and 0 deletions

View file

@ -0,0 +1,38 @@
package storage
//go:generate mockgen -source=storage.go -destination=mock/mock_storage.go -package=mock
import (
"context"
"io"
"time"
)
// FileInfo represents metadata about a stored file
type FileInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
ContentType string `json:"content_type"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
URL string `json:"url"`
}
// Storage defines the interface for file storage operations
type Storage interface {
// Save stores a file and returns its FileInfo
Save(ctx context.Context, name string, contentType string, reader io.Reader) (*FileInfo, error)
// Get retrieves a file by its ID
Get(ctx context.Context, id string) (io.ReadCloser, *FileInfo, error)
// Delete removes a file by its ID
Delete(ctx context.Context, id string) error
// List returns a list of files with optional prefix
List(ctx context.Context, prefix string, limit int, offset int) ([]*FileInfo, error)
// Exists checks if a file exists
Exists(ctx context.Context, id string) (bool, error)
}