Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrObjectNotFound = errors.New("object not found")
)
Errors
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(router *gin.RouterGroup, deps *app.RuntimeDeps)
RegisterRoutes registers storage routes.
Types ¶
type CreateDownloadURLInput ¶
CreateDownloadURLInput represents the input for creating a download URL.
type CreateUploadURLInput ¶
CreateUploadURLInput represents the input for creating an upload URL.
type ObjectMeta ¶
type ObjectMeta struct {
ID string
TenantID string
ObjectKey string
FileName string
CreatedAt time.Time
UpdatedAt time.Time
}
ObjectMeta represents object metadata.
type ObjectRepositoryPostgres ¶
type ObjectRepositoryPostgres struct {
// contains filtered or unexported fields
}
ObjectRepositoryPostgres implements Repository using PostgreSQL.
func (*ObjectRepositoryPostgres) GetObjectMeta ¶
func (r *ObjectRepositoryPostgres) GetObjectMeta(ctx context.Context, tenantID, objectID string) (ObjectMeta, error)
GetObjectMeta retrieves object metadata by ID and tenant ID.
func (*ObjectRepositoryPostgres) SaveObjectMeta ¶
func (r *ObjectRepositoryPostgres) SaveObjectMeta(ctx context.Context, obj ObjectMeta) (ObjectMeta, error)
SaveObjectMeta saves object metadata to the database.
type Provider ¶
type Provider interface {
PresignPut(ctx context.Context, objectKey string, ttlSeconds int) (string, error)
PresignGet(ctx context.Context, objectKey string, ttlSeconds int) (string, error)
}
Provider defines the contract for storage providers.
type Repository ¶
type Repository interface {
SaveObjectMeta(ctx context.Context, obj ObjectMeta) (ObjectMeta, error)
GetObjectMeta(ctx context.Context, tenantID, objectID string) (ObjectMeta, error)
}
Repository defines the contract for storage persistence.
func NewObjectRepositoryPostgres ¶
func NewObjectRepositoryPostgres(db *database.Postgres) Repository
NewObjectRepositoryPostgres creates a new PostgreSQL object repository.
type Service ¶
type Service interface {
CreateUploadURL(ctx context.Context, in CreateUploadURLInput) (SignedURL, error)
CreateDownloadURL(ctx context.Context, in CreateDownloadURLInput) (SignedURL, error)
}
Service defines the contract for storage business logic.
type SignedURL ¶
type SignedURL struct {
URL string
}
SignedURL represents a signed URL for upload/download operations.
type StorageHandler ¶
type StorageHandler struct {
// contains filtered or unexported fields
}
StorageHandler handles HTTP requests for storage operations.
func NewStorageHandler ¶
func NewStorageHandler(service Service, logger *logger.Logger) *StorageHandler
NewStorageHandler creates a new storage handler.
func (*StorageHandler) GetDownloadURL ¶
func (h *StorageHandler) GetDownloadURL(c *gin.Context)
GetDownloadURL handles POST /storage/download-url
func (*StorageHandler) GetUploadURL ¶
func (h *StorageHandler) GetUploadURL(c *gin.Context)
GetUploadURL handles POST /storage/upload-url
type StorageService ¶
type StorageService struct {
// contains filtered or unexported fields
}
StorageService implements the Service interface for storage operations.
func NewStorageService ¶
NewStorageService creates a new storage service instance.
func (*StorageService) CreateDownloadURL ¶
func (s *StorageService) CreateDownloadURL(ctx context.Context, in CreateDownloadURLInput) (SignedURL, error)
CreateDownloadURL generates a presigned URL for downloading a file.
func (*StorageService) CreateUploadURL ¶
func (s *StorageService) CreateUploadURL(ctx context.Context, in CreateUploadURLInput) (SignedURL, error)
CreateUploadURL generates a presigned URL for uploading a file and saves metadata.
func (*StorageService) WithRepository ¶
func (s *StorageService) WithRepository(repo Repository) *StorageService
WithRepository sets the repository for the storage service.