storage

package
v1.11.8 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package storage defines object storage operations and local and S3-backed implementations. Applications own authorization, encryption, retention, malware scanning, and data residency.

Index

Constants

This section is empty.

Variables

View Source
var ErrS3NotConfigured = errors.New("storage: S3 provider is not configured")

ErrS3NotConfigured indicates an uninitialized S3 client.

Functions

func GenerateCloudFrontURL

func GenerateCloudFrontURL(domain, key string) string

GenerateCloudFrontURL formats a CloudFront CDN URL for asset distribution.

Types

type LocalStorageProvider

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

LocalStorageProvider implements local disk object storage Provider.

func NewLocalStorageProvider

func NewLocalStorageProvider(baseDir string) *LocalStorageProvider

NewLocalStorageProvider initializes a local disk storage provider.

func (*LocalStorageProvider) GetPresignedURL

func (l *LocalStorageProvider) GetPresignedURL(ctx context.Context, key string, expiry time.Duration) (string, error)

GetPresignedURL returns the local serving path; it does not create a signature.

func (*LocalStorageProvider) Upload

func (l *LocalStorageProvider) Upload(ctx context.Context, key string, data []byte, contentType string) (string, error)

Upload writes one object beneath the configured local storage root.

type Provider

type Provider interface {
	Upload(ctx context.Context, key string, data []byte, contentType string) (string, error)
	GetPresignedURL(ctx context.Context, key string, expiry time.Duration) (string, error)
}

Provider defines the object storage contract for cloud S3 and local storage drivers.

type S3Client

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

S3Client stores private objects using the AWS credential chain, SHA-256 integrity checks, and server-side encryption.

func NewS3Client

func NewS3Client(ctx context.Context, config S3Config) (*S3Client, error)

NewS3Client validates configuration and loads the AWS credential chain.

func (*S3Client) GetPresignedURL

func (client *S3Client) GetPresignedURL(ctx context.Context, key string, expiry time.Duration) (string, error)

GetPresignedURL returns a bounded-lifetime private object download URL.

func (*S3Client) Upload

func (client *S3Client) Upload(ctx context.Context, key string, data []byte, contentType string) (string, error)

Upload stores one bounded encrypted object with a SHA-256 checksum.

type S3Config

type S3Config struct {
	Bucket            string
	Region            string
	Prefix            string
	EndpointURL       string
	PublicBaseURL     string
	KMSKeyID          string
	UsePathStyle      bool
	AllowInsecureHTTP bool
	MaxUploadBytes    int
	Timeout           time.Duration
	RetryAttempts     int
}

S3Config defines bucket, endpoint, encryption, retry, and capacity policy.

Jump to

Keyboard shortcuts

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