Documentation
¶
Overview ¶
Package local keeps objects in a directory under the project, which is the backend api:cli-dev and a test run on: a developer loop that needs an S3 endpoint before a file can be stored is one nobody starts with.
import _ "github.com/shibukawa/popcornweb/storage/local"
Each object is one file under the directory, with a sidecar carrying the media type and user metadata a file system does not keep.
Index ¶
- type Bucket
- func (b *Bucket) Delete(ctx context.Context, key string) error
- func (b *Bucket) Get(ctx context.Context, key string) (*storage.Object, error)
- func (b *Bucket) Head(ctx context.Context, key string) (*storage.ObjectInfo, error)
- func (b *Bucket) List(ctx context.Context, options storage.ListOptions) (*storage.ListPage, error)
- func (b *Bucket) Presign(ctx context.Context, key string, options storage.PresignOptions) (*url.URL, error)
- func (b *Bucket) Put(ctx context.Context, key string, body io.Reader, options storage.PutOptions) error
- func (b *Bucket) VerifySignedRequest(r *http.Request, key string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket is one directory of objects.
func New ¶
New opens a directory as a bucket named name, for a caller building one outside the configuration, such as a test.
func (*Bucket) List ¶
List walks the directory in key order. The cursor is the last key of the previous page, so a page after a deletion still continues.
func (*Bucket) Presign ¶
func (b *Bucket) Presign(ctx context.Context, key string, options storage.PresignOptions) (*url.URL, error)
Presign returns a path under storage.SignedPathPrefix that the application serves itself, signed with a key this process generated when the bucket opened. The URL is relative: the page that hands it to a browser is on the same origin, and the backend does not know the host it is served on. It lives for options.Expires, or storage.DefaultPresignExpiry, and dies with the process, which is what a development loop wants.
func (*Bucket) Put ¶
func (b *Bucket) Put(ctx context.Context, key string, body io.Reader, options storage.PutOptions) error
Put writes one object and its sidecar. The bytes land under a temporary name and are renamed into place, so a reader never sees a half-written object.
func (*Bucket) VerifySignedRequest ¶
VerifySignedRequest is the storage.SelfServing half of Presign: the signature covers the method, the key and the expiry, so a URL signed for a GET does not authorize a PUT and one past its expiry authorizes nothing.