storage

package
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupStorageByPrefix added in v1.6.0

func CleanupStorageByPrefix(ctx context.Context, prefix string) error

func CopyFileFromStorage added in v1.6.0

func CopyFileFromStorage(ctx context.Context, storageKey, destPath string) error

func CopyFileToStorage added in v1.6.0

func CopyFileToStorage(ctx context.Context, sourcePath, storageKey string) error

func EnsureStorageKeyExists added in v1.6.0

func EnsureStorageKeyExists(ctx context.Context, storageKey string) error

func GenerateBackupKey added in v1.6.0

func GenerateBackupKey(filename string) string

GenerateBackupKey generates a storage key for backup files

func GenerateUserConfigKey added in v1.6.0

func GenerateUserConfigKey(userID uuid.UUID) string

GenerateUserConfigKey generates a storage key for user rmapi config

func GenerateUserConfigPrefix added in v1.6.0

func GenerateUserConfigPrefix(userID uuid.UUID) string

GenerateUserConfigPrefix returns the storage prefix for a user's configs

func GenerateUserDocumentKey added in v1.6.0

func GenerateUserDocumentKey(userID uuid.UUID, prefix, filename string, multiUserMode bool) string

GenerateUserDocumentKey generates a storage key for user documents

func GenerateUserDocumentPrefix added in v1.6.0

func GenerateUserDocumentPrefix(userID uuid.UUID) string

GenerateUserDocumentPrefix returns the storage prefix for a user's documents

func GenerateUserPrefix added in v1.6.0

func GenerateUserPrefix(userID uuid.UUID) string

GenerateUserPrefix returns the storage prefix for a user's files

func GetStorageType added in v1.6.0

func GetStorageType() string

GetStorageType returns the type of the current storage backend

func InitializeStorage added in v1.6.0

func InitializeStorage() error

InitializeStorage initializes the global storage backend based on configuration

func IsBackupStorageKey added in v1.6.0

func IsBackupStorageKey(storageKey string) bool

IsBackupStorageKey checks if a storage key is for a backup file

func IsUserStorageKey added in v1.6.0

func IsUserStorageKey(storageKey string, userID uuid.UUID) bool

IsUserStorageKey checks if a storage key belongs to a specific user

func MoveFileToStorage added in v1.6.0

func MoveFileToStorage(ctx context.Context, sourcePath, storageKey string) error

func MoveInStorage added in v1.6.0

func MoveInStorage(ctx context.Context, srcKey, dstKey string) error

func ParseUserIDFromKey added in v1.6.0

func ParseUserIDFromKey(storageKey string) (uuid.UUID, error)

ParseUserIDFromKey extracts the user ID from a storage key, if present

func SanitizeStorageKey added in v1.6.0

func SanitizeStorageKey(key string) string

SanitizeStorageKey ensures the storage key is safe to use

func StreamToResponse added in v1.6.0

func StreamToResponse(ctx context.Context, c *gin.Context, storageKey, filename, contentType string) error

func ValidateStorageConfig added in v1.6.0

func ValidateStorageConfig(cfg StorageConfig) error

ValidateStorageConfig validates the storage configuration

Types

type FilesystemBackend added in v1.6.0

type FilesystemBackend struct {
	// contains filtered or unexported fields
}

func NewFilesystemBackend added in v1.6.0

func NewFilesystemBackend(basePath string) *FilesystemBackend

func (*FilesystemBackend) Copy added in v1.6.0

func (fs *FilesystemBackend) Copy(ctx context.Context, srcKey, dstKey string) error

func (*FilesystemBackend) Delete added in v1.6.0

func (fs *FilesystemBackend) Delete(ctx context.Context, key string) error

func (*FilesystemBackend) Exists added in v1.6.0

func (fs *FilesystemBackend) Exists(ctx context.Context, key string) (bool, error)

func (*FilesystemBackend) Get added in v1.6.0

func (fs *FilesystemBackend) Get(ctx context.Context, key string) (io.ReadCloser, error)

func (*FilesystemBackend) GetInfo added in v1.6.0

func (fs *FilesystemBackend) GetInfo(ctx context.Context, key string) (*StorageInfo, error)

func (*FilesystemBackend) List added in v1.6.0

func (fs *FilesystemBackend) List(ctx context.Context, prefix string) ([]string, error)

func (*FilesystemBackend) ListWithInfo added in v1.6.0

func (fs *FilesystemBackend) ListWithInfo(ctx context.Context, prefix string) ([]StorageInfo, error)

func (*FilesystemBackend) Put added in v1.6.0

func (fs *FilesystemBackend) Put(ctx context.Context, key string, data io.Reader) error

type S3Backend added in v1.6.0

type S3Backend struct {
	// contains filtered or unexported fields
}

func NewS3Backend added in v1.6.0

func NewS3Backend(client *s3.Client, bucket string) *S3Backend

func (*S3Backend) Copy added in v1.6.0

func (s3b *S3Backend) Copy(ctx context.Context, srcKey, dstKey string) error

func (*S3Backend) Delete added in v1.6.0

func (s3b *S3Backend) Delete(ctx context.Context, key string) error

func (*S3Backend) Exists added in v1.6.0

func (s3b *S3Backend) Exists(ctx context.Context, key string) (bool, error)

func (*S3Backend) Get added in v1.6.0

func (s3b *S3Backend) Get(ctx context.Context, key string) (io.ReadCloser, error)

func (*S3Backend) GetInfo added in v1.6.0

func (s3b *S3Backend) GetInfo(ctx context.Context, key string) (*StorageInfo, error)

func (*S3Backend) List added in v1.6.0

func (s3b *S3Backend) List(ctx context.Context, prefix string) ([]string, error)

func (*S3Backend) ListWithInfo added in v1.6.0

func (s3b *S3Backend) ListWithInfo(ctx context.Context, prefix string) ([]StorageInfo, error)

func (*S3Backend) Put added in v1.6.0

func (s3b *S3Backend) Put(ctx context.Context, key string, data io.Reader) error

type StorageBackend added in v1.6.0

type StorageBackend interface {
	// Put stores data at the given key
	Put(ctx context.Context, key string, data io.Reader) error

	// Get retrieves data from the given key
	Get(ctx context.Context, key string) (io.ReadCloser, error)

	// Delete removes the object at the given key
	Delete(ctx context.Context, key string) error

	// List returns all keys with the given prefix
	List(ctx context.Context, prefix string) ([]string, error)

	// Exists checks if an object exists at the given key
	Exists(ctx context.Context, key string) (bool, error)

	// Copy copies an object from srcKey to dstKey
	Copy(ctx context.Context, srcKey, dstKey string) error
}

StorageBackend defines the interface for different storage implementations

type StorageBackendWithInfo added in v1.6.0

type StorageBackendWithInfo interface {
	StorageBackend

	// ListWithInfo returns objects with metadata
	ListWithInfo(ctx context.Context, prefix string) ([]StorageInfo, error)

	// GetInfo returns metadata for a single object
	GetInfo(ctx context.Context, key string) (*StorageInfo, error)
}

StorageBackendWithInfo extends StorageBackend with metadata operations

func GetStorageBackend added in v1.6.0

func GetStorageBackend() StorageBackendWithInfo

GetStorageBackend returns the initialized global storage backend

type StorageConfig added in v1.6.0

type StorageConfig struct {
	Backend          string
	DataDir          string
	S3Endpoint       string
	S3Region         string
	S3Bucket         string
	S3AccessKeyID    string
	S3SecretKey      string
	S3ForcePathStyle bool
}

StorageConfig holds configuration for storage backends

func GetStorageConfig added in v1.6.0

func GetStorageConfig() StorageConfig

GetStorageConfig returns storage configuration from environment variables

type StorageInfo added in v1.6.0

type StorageInfo struct {
	Key          string
	Size         int64
	LastModified string
}

StorageInfo provides metadata about stored objects

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL