Documentation
¶
Overview ¶
Package files serves an object bucket over a route prefix.
It exists so that every module that accepts user uploads gets the same three guarantees without rewriting them: the stored type is the one deduced from the bytes, the key is minted by the server, and the size is checked before a single byte of the body is buffered.
Index ¶
Constants ¶
const ( // DefaultMaxSize is the largest upload accepted unless the caller says otherwise. DefaultMaxSize = 10 << 20 // 10 MiB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket interface {
Put(key string, data []byte, contentType string) error
Get(key string) (data []byte, contentType string, err error)
}
Bucket is the storage this package needs. r2.Bucket satisfies it.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store registers the upload and serve handlers for one bucket under one prefix.
func New ¶
New builds a Store on the safe defaults: raster images only, 10 MiB. prefix must end in "/" — it is matched by prefix, and the key is what hangs off it.
func (*Store) Allow ¶
Allow narrows or widens the accepted types. Never add SVG or HTML: both carry JavaScript and, served from your own domain, execute in your origin.