storage

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: BSD-3-Clause-LBNL Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Context = ContextStorage("storage")
	// Cloud Specific const
	CloudType             = "cloud_type"
	BucketName            = "bucket_name"
	Prefix                = "prefix"
	Custom                = "custom"
	AccessId              = "access_id"
	SecretKey             = "secret_key"
	Endpoint              = "endpoint"
	Region                = "region"
	InitBucket            = "init_bucket"
	LocalStorageType Type = "LocalStorage"
	SecureLocation        = "secure_location"
	// Auth
	CloudKey    = "AWS_ACCESS_KEY" // #nosec G101
	CloudSecret = "AWS_SECRET_KEY" // #nosec G101
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudStorage

type CloudStorage struct {
	BucketRef   *blob.Bucket
	BucketName  string
	Prefix      string
	StorageName string
}

func (*CloudStorage) FindAllFiles

func (s *CloudStorage) FindAllFiles(folder string, fullPath bool) ([]string, error)

func (*CloudStorage) GetPrefix

func (s *CloudStorage) GetPrefix() string

func (*CloudStorage) Name

func (s *CloudStorage) Name() string

func (*CloudStorage) ReadFile

func (s *CloudStorage) ReadFile(filename string) ([]byte, error)

ReadFile read file from Cloud Provider and return byte array

func (*CloudStorage) WriteFile

func (s *CloudStorage) WriteFile(filename string, data []byte) error

WriteFile persists data to Cloud Provider Storage returning error if operation failed

type ContextStorage

type ContextStorage string

type LocalStorage

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

LocalStorage default storage engine

func (*LocalStorage) FindAllFiles

func (s *LocalStorage) FindAllFiles(folder string, fullPath bool) ([]string, error)

func (*LocalStorage) GetPrefix

func (s *LocalStorage) GetPrefix() string

GetPrefix should always return "" for local storage

func (*LocalStorage) Name

func (s *LocalStorage) Name() string

func (*LocalStorage) ReadFile

func (s *LocalStorage) ReadFile(filename string) ([]byte, error)

ReadFile returns a byte array of file content

func (*LocalStorage) WriteFile

func (s *LocalStorage) WriteFile(filename string, data []byte) error

WriteFile writes file to disk and returns an error if operation failed

type Resolver

type Resolver struct {
	URL *url.URL
}

AWS Crud

func (*Resolver) ResolveEndpoint

func (r *Resolver) ResolveEndpoint(ctx context.Context, params s3.EndpointParameters) (transport.Endpoint, error)

type Storage

type Storage interface {
	WriteFile(filename string, data []byte) error                // WriteFile returns error or writes byte array to destination
	ReadFile(filename string) ([]byte, error)                    // ReadFile returns byte array or error with data from file
	FindAllFiles(folder string, fullPath bool) ([]string, error) // FindAllFiles recursively list all files for a given path
	Name() string                                                // Name of storage engine
	GetPrefix() string                                           // Prefix used by storage engine
}

TODO: pull all the cloud based interaction into a Plugin System

func NewCloudStorage

func NewCloudStorage(c context.Context, encoder contract.CipherEncoder) (Storage, error)

NewCloudStorage creates a CloudStorage instance using context‑provided config. It validates context, parses app data, supports custom S3 endpoints or native cloud URLs, initializes the bucket (creating it if requested), and returns a configured Storage.

func NewLocalStorage

func NewLocalStorage(ctx context.Context) Storage

type Type

type Type string

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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