storage

package
v0.2.39 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewGCSStorage func(cfg GCSConfig) (ImageStorage, error)

NewGCSStorage creates a new GCS storage This is a placeholder that will be implemented in the gcs package

View Source
var NewLocalStorage func(cfg LocalConfig) (ImageStorage, error)

NewLocalStorage creates a new local filesystem storage This is a placeholder that will be implemented in the local package

Functions

This section is empty.

Types

type Config

type Config struct {
	// Type is the storage backend type ("local", "gcs")
	Type string

	// Local storage configuration
	Local LocalConfig

	// GCS storage configuration
	GCS GCSConfig
}

Config contains configuration for storage backends

type GCSConfig

type GCSConfig struct {
	// Bucket is the GCS bucket name
	Bucket string

	// Prefix is the path prefix within the bucket
	Prefix string

	// CredentialsFile is the path to the service account JSON file (optional)
	// If empty, uses Application Default Credentials
	CredentialsFile string

	// CredentialsJSON is the service account JSON content (optional)
	// Can be raw JSON or base64 encoded. Takes precedence over CredentialsFile.
	CredentialsJSON string

	// SignedURLExpiration is the duration for signed URLs (default: 24h)
	SignedURLExpiration time.Duration

	// UseSignedURLs determines whether to return signed URLs or public URLs
	UseSignedURLs bool
}

GCSConfig contains configuration for Google Cloud Storage

type ImageStorage

type ImageStorage interface {
	// Store saves an image and returns an accessible URL
	Store(ctx context.Context, image *interfaces.GeneratedImage, metadata StorageMetadata) (string, error)

	// Delete removes an image by URL
	Delete(ctx context.Context, url string) error

	// Get retrieves image data by URL (optional, may not be supported by all backends)
	Get(ctx context.Context, url string) ([]byte, error)

	// Name returns the storage backend name
	Name() string
}

ImageStorage defines the interface for storing and retrieving generated images

func NewStorageFromConfig

func NewStorageFromConfig(cfg Config) (ImageStorage, error)

NewStorageFromConfig creates a storage backend from configuration

type LocalConfig

type LocalConfig struct {
	// Path is the base directory for storing images
	Path string

	// BaseURL is the URL prefix for accessing stored images (optional)
	// If empty, file paths will be returned instead of URLs
	BaseURL string
}

LocalConfig contains configuration for local filesystem storage

type StorageMetadata

type StorageMetadata struct {
	// OrgID is the organization ID for multi-tenancy
	OrgID string

	// ThreadID is the conversation thread ID
	ThreadID string

	// MessageID is the message ID
	MessageID string

	// Prompt is the original prompt used to generate the image
	Prompt string

	// Tags contains custom tags for the image
	Tags map[string]string

	// CreatedAt is the timestamp when the image was created
	CreatedAt time.Time
}

StorageMetadata contains metadata for stored images

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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