bucket

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package seaweedfs provides a small client for SeaweedFS's S3-compatible API. It can idempotently initialise a bucket and an optional virtual root prefix, then upload ZIP files with the AWS SDK v2 multipart uploader.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client owns an S3 client and a multipart uploader configured for SeaweedFS.

func New

func New(ctx context.Context, cfg Config) (*Client, error)

New creates a SeaweedFS S3 client. It deliberately uses path-style S3 requests, which work reliably for in-cluster SeaweedFS service endpoints.

func (*Client) EnsureInitialRoot

func (c *Client) EnsureInitialRoot(ctx context.Context) error

EnsureInitialRoot prepares first-run storage. It is safe to call from multiple application replicas: it creates the bucket when absent and uses an empty .keep object only to make an otherwise-empty root prefix visible.

func (*Client) UploadZip

func (c *Client) UploadZip(ctx context.Context, body io.Reader, size int64, objectName string) (Object, error)

UploadZip uploads ZIP data. For files, prefer UploadZipFile: an *os.File is seekable, allowing the SDK to retry upload work more efficiently.

func (*Client) UploadZipFile

func (c *Client) UploadZipFile(ctx context.Context, filePath, objectName string) (Object, error)

UploadZipFile uploads a local ZIP file below RootPrefix. objectName must be relative to RootPrefix, e.g. "archives/database-2026-06-26.zip".

type Config

type Config struct {
	Endpoint    string
	Region      string
	AccessKey   string
	SecretKey   string
	Bucket      string
	RootPrefix  string
	PartSize    int64
	Concurrency int
}

Config contains the connection and upload settings.

Endpoint example: http://seaweedfs-s3.cmaestro-db.svc.cluster.local:8333 RootPrefix example: root or application-data. It is not a real directory; it becomes a prefix in object keys.

type Object

type Object struct {
	Bucket    string
	Key       string
	ETag      string
	VersionID string
	Location  string
	Size      int64
}

Object is the useful result of a successful upload.

Jump to

Keyboard shortcuts

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