backend

package
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Save stores data under the given filename and returns the URL or path to
	// the stored image.
	Save(ctx context.Context, data []byte, filename string) (string, error)
}

Backend is the interface implemented by all storage backends.

type LocalBackend

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

LocalBackend saves images to the local filesystem.

func NewLocalBackend added in v0.2.2

func NewLocalBackend(dir string) *LocalBackend

NewLocalBackend creates a LocalBackend that saves images under dir.

func (*LocalBackend) Save

func (b *LocalBackend) Save(_ context.Context, data []byte, filename string) (string, error)

Save writes data to dir/filename and returns a relative Markdown-compatible URL.

type NodeBBBackend

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

NodeBBBackend uploads images to a NodeBB forum instance.

func NewNodeBBBackend

func NewNodeBBBackend(baseURL string) (*NodeBBBackend, error)

NewNodeBBBackend creates a NodeBBBackend for the given base URL.

func (*NodeBBBackend) Save

func (b *NodeBBBackend) Save(ctx context.Context, data []byte, filename string) (string, error)

Save authenticates (if needed) and uploads an image to NodeBB, returning the URL.

type R2Backend

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

R2Backend uploads images to Cloudflare R2 via the S3-compatible API.

func NewR2Backend

func NewR2Backend(bucket, publicURL, endpoint, prefix string) (*R2Backend, error)

NewR2Backend creates an R2Backend using credentials from environment variables R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY.

func (*R2Backend) Save

func (b *R2Backend) Save(ctx context.Context, data []byte, filename string) (string, error)

Save uploads data to R2 and returns the public URL of the uploaded object.

Jump to

Keyboard shortcuts

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