storage

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SpacePrefix

func SpacePrefix(tenantID, spaceID uuid.UUID) string

SpacePrefix returns the S3 prefix for a space's shared files.

Types

type ObjectInfo

type ObjectInfo struct {
	Key          string
	Size         int64
	LastModified time.Time
}

ObjectInfo describes an object in S3.

type S3Client

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

S3Client provides S3/MinIO file storage for spaces.

func NewS3Client

func NewS3Client(cfg *config.Config) *S3Client

NewS3Client creates an S3Client from config. Panics if S3URL is empty.

func NewS3ClientFromParams

func NewS3ClientFromParams(endpoint, accessKey, secretKey, bucket, region string) *S3Client

NewS3ClientFromParams creates an S3Client from explicit parameters (for non-airlock binaries like Anchor).

func (*S3Client) CopyObject

func (c *S3Client) CopyObject(ctx context.Context, srcKey, dstKey string) error

CopyObject performs a server-side copy from srcKey to dstKey within the same bucket.

func (*S3Client) DeleteObject

func (c *S3Client) DeleteObject(ctx context.Context, key string) error

DeleteObject deletes the object at the given key.

func (*S3Client) DeletePrefix

func (c *S3Client) DeletePrefix(ctx context.Context, prefix string) error

DeletePrefix deletes all objects under the given prefix.

func (*S3Client) EnsureBucket

func (c *S3Client) EnsureBucket(ctx context.Context) error

func (*S3Client) GetObject

func (c *S3Client) GetObject(ctx context.Context, key string) (io.ReadCloser, error)

GetObject returns a reader for the object at the given key. Caller must close the reader.

func (*S3Client) HeadObject

func (c *S3Client) HeadObject(ctx context.Context, key string) (ObjectInfo, string, error)

HeadObject returns metadata for the object at the given key.

func (*S3Client) ListObjects

func (c *S3Client) ListObjects(ctx context.Context, prefix string) ([]ObjectInfo, error)

ListObjects lists objects under the given prefix.

func (*S3Client) Ping

func (c *S3Client) Ping(ctx context.Context) error

EnsureBucket creates the bucket if it doesn't exist. Ping is a read-only liveness check: HeadBucket on the configured bucket. Returns nil if S3/MinIO is reachable and the bucket exists.

func (*S3Client) PresignGetURL

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

PresignGetURL returns a presigned GET URL for downloading a file.

func (*S3Client) PresignPutURL

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

PresignPutURL returns a presigned PUT URL for uploading a file.

func (*S3Client) PublicPresignGetURL

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

PublicPresignGetURL returns a presigned GET URL signed for the public endpoint. If S3_URL_PUBLIC is not configured, falls back to the internal presigned URL.

func (*S3Client) PutObject

func (c *S3Client) PutObject(ctx context.Context, key string, reader io.Reader, size int64) error

PutObject uploads data from a reader to the given key. If the reader is not seekable, it is buffered into memory first.

func (*S3Client) SyncDown

func (c *S3Client) SyncDown(ctx context.Context, tenantID, spaceID uuid.UUID, localRoot string) error

SyncDown downloads the shared/ directory from S3 to localRoot/shared/.

func (*S3Client) SyncPath

func (c *S3Client) SyncPath(ctx context.Context, tenantID, spaceID uuid.UUID, relPath, localRoot string) error

SyncPath uploads a single file from localRoot to S3. relPath is relative to localRoot (e.g., "shared/foo.txt").

func (*S3Client) SyncUp

func (c *S3Client) SyncUp(ctx context.Context, tenantID, spaceID uuid.UUID, localRoot string) error

SyncUp uploads the shared/ directory from localRoot/shared/ to S3.

Jump to

Keyboard shortcuts

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