storage

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildObjectKey

func BuildObjectKey(projectID, tenantID, fileType, fileID, ext string) (string, error)

BuildObjectKey returns the canonical storage key. General: {project_id}/{file_type}/{uuid}{ext} SaaS (non-empty tenantID): {project_id}/{tenant_id}/{file_type}/{uuid}{ext}

func TenantObjectPrefix added in v1.8.4

func TenantObjectPrefix(projectID, tenantID string) (string, error)

TenantObjectPrefix returns the S3 key prefix for all objects belonging to a SaaS tenant. Example: "protiva_bqyu3/01KXZ…/"

func ValidateTenantIDSegment added in v1.8.4

func ValidateTenantIDSegment(tenantID string) (string, error)

ValidateTenantIDSegment returns a trimmed tenant id or an error when the value is unsafe for object keys.

Types

type ObjectStorage

type ObjectStorage interface {
	Upload(ctx context.Context, key string, body io.Reader, contentType string, size int64) (publicURL string, err error)
	DeleteObjects(ctx context.Context, keys []string) (failed []string, err error)
	DeletePrefix(ctx context.Context, prefix string) (deleted int, failed []string, err error)
}

ObjectStorage uploads and deletes objects in project-configured S3-compatible storage.

type ProjectS3Storage

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

ProjectS3Storage implements ObjectStorage using aws-sdk-go-v2 and project storage settings.

func NewProjectS3Storage

func NewProjectS3Storage(project *models.Project, cfg *models.Config) (*ProjectS3Storage, error)

NewProjectS3Storage builds an S3-compatible client from project storage settings and platform free-cloud config.

func (*ProjectS3Storage) DeleteObjects

func (s *ProjectS3Storage) DeleteObjects(ctx context.Context, keys []string) ([]string, error)

DeleteObjects removes objects; returns keys that failed to delete.

func (*ProjectS3Storage) DeletePrefix added in v1.8.4

func (s *ProjectS3Storage) DeletePrefix(ctx context.Context, prefix string) (int, []string, error)

DeletePrefix lists all objects under prefix and deletes them.

func (*ProjectS3Storage) PublicURL

func (s *ProjectS3Storage) PublicURL(key string) string

PublicURL builds the object URL from PublicBaseURL or endpoint/bucket/key.

func (*ProjectS3Storage) Upload

func (s *ProjectS3Storage) Upload(ctx context.Context, key string, body io.Reader, contentType string, size int64) (string, error)

Upload streams an object to S3.

Jump to

Keyboard shortcuts

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