Documentation
¶
Index ¶
Constants ¶
View Source
const ( MaxFileSize = 20 * 1024 * 1024 // 20MB SignedURLDuration = 12 * time.Hour UploadURLDuration = time.Hour )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileIdentifier ¶
type ImageService ¶
type ImageService interface {
Upload(ctx context.Context, req *ImageUploadRequest) (string, error)
GetUploadURL(fileID FileIdentifier) (string, error)
GetURL(fileID FileIdentifier) (string, error)
GetURI(fileID FileIdentifier) string
Delete(ctx context.Context, fileID FileIdentifier) error
DeleteAllInvalid(ctx context.Context, bucketName string, validObjectKeys []string) error
}
func NewImageService ¶
func NewImageService( validate *validator.Validate, storageRepo StorageRepository, ) ImageService
type ImageUploadRequest ¶
type ImageUploadRequest struct {
ImageData []byte `validate:"required"`
ContentType string `validate:"required,oneof=image/jpeg image/png image/jpg image/webp"`
FileSize int64 `validate:"required,min=1"`
FileIdentifier
}
type StorageRepository ¶
type StorageRepository interface {
Upload(ctx context.Context, req *StorageUploadRequest) error
Delete(ctx context.Context, fileID FileIdentifier) error
GetUploadURL(fileID FileIdentifier, expiration time.Duration) (string, error)
GetSignedURL(fileID FileIdentifier, expiration time.Duration) (string, error)
GetAllObjectKeys(ctx context.Context, bucketName string) ([]string, error)
Exists(ctx context.Context, fileID FileIdentifier) (bool, error)
ToURI(fi FileIdentifier) string
Close() error
}
func NewGCSStorageRepository ¶
func NewGCSStorageRepository() (StorageRepository, error)
type StorageUploadRequest ¶
Click to show internal directories.
Click to hide internal directories.