local

package
v0.3.4 Latest Latest
Warning

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

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

Documentation

Overview

Package local stores objects on the local disk: development's storage driver (ADR-0075). Objects live under <root>/objects/<key>; each has a sidecar under <root>/meta/<key>.json with its content type, ETag and metadata. Signed URLs are HMAC-signed links served by Store.Handler, which the app mounts (for example at /storage/).

Stability: experimental (ADR-0054).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option configures a Store.

func WithSigner

func WithSigner(secret []byte, baseURL string) Option

WithSigner enables signed URLs: secret signs them and baseURL (such as http://127.0.0.1:8080/storage) is where Store.Handler is mounted.

type Store

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

Store is a local-disk storage.Store.

func New

func New(root string, opts ...Option) (*Store, error)

New opens the store under root, creating it.

func (*Store) Copy

func (s *Store) Copy(ctx context.Context, src, dst string) (storage.Object, error)

Copy implements storage.Store.

func (*Store) Delete

func (s *Store) Delete(_ context.Context, key string) error

Delete implements storage.Store.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) (io.ReadCloser, storage.Object, error)

Get implements storage.Store.

func (*Store) Handler

func (s *Store) Handler() http.Handler

Handler serves signed URLs: GET downloads the object, PUT stores the body. Mount it where WithSigner's baseURL points, with the prefix stripped (http.StripPrefix).

func (*Store) Info

func (s *Store) Info() storage.Info

Info implements storage.Store.

func (*Store) List

func (s *Store) List(ctx context.Context, opts storage.ListOptions) (storage.Page, error)

List implements storage.Store. The cursor is the last key of the previous page.

func (*Store) Ping

func (s *Store) Ping(context.Context) error

Ping implements storage.Store.

func (*Store) Put

func (s *Store) Put(_ context.Context, key string, r io.Reader, _ int64, opts storage.PutOptions) (storage.Object, error)

Put implements storage.Store.

func (*Store) Root

func (s *Store) Root() string

Root is the store's directory.

func (*Store) SignedURL

func (s *Store) SignedURL(_ context.Context, key, method string, expiry time.Duration) (string, error)

SignedURL implements storage.Store: baseURL/<key>?exp=<unix>&method=&sig=.

func (*Store) Stat

func (s *Store) Stat(_ context.Context, key string) (storage.Object, error)

Stat implements storage.Store.

Jump to

Keyboard shortcuts

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