Documentation
¶
Overview ¶
Package s3 is a platform module: S3 compatible object storage — MinIO locally, any S3 in production — for the files of the project.
The storage API is taply's: Put into a bucket that is created on first use, with an anonymous read policy when the files are served publicly, and Delete. On top of it come streaming uploads, reads and signed links.
Index ¶
- Variables
- type Config
- type Module
- type Storage
- func (s *Storage) Client() *minio.Client
- func (s *Storage) Delete(ctx context.Context, bucket, objectName string) error
- func (s *Storage) Get(ctx context.Context, bucket, objectPath string) (io.ReadCloser, error)
- func (s *Storage) PublicURL(bucket, objectPath string) string
- func (s *Storage) Put(ctx context.Context, bucket string, anonymousRead bool, ...) (string, error)
- func (s *Storage) PutStream(ctx context.Context, bucket string, anonymousRead bool, ...) (string, error)
- func (s *Storage) SignedURL(ctx context.Context, bucket, objectPath string, ttl time.Duration) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("s3: object not found")
ErrNotFound is returned for an object that does not exist.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Endpoint string // host:port, without the scheme
AccessKey string
SecretKey string
UseSSL bool
Region string
// PublicURL is where public buckets are served from, for example the /storage/ path
// of the nginx in front of the service. Empty means links point at the endpoint.
PublicURL string
}
Config holds module settings. Load fills it from the environment; the platform generator writes the Load call into the project's config.gen.go.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module implements platform.Module.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage stores files in buckets.
func (*Storage) Delete ¶
Delete removes an object. Removing an object that does not exist is not an error.
func (*Storage) Get ¶
Get opens an object for reading. ErrNotFound is returned when it does not exist.
func (*Storage) Put ¶
func (s *Storage) Put(ctx context.Context, bucket string, anonymousRead bool, objectPath, contentType string, b []byte) (string, error)
Put stores an object and returns its path. The bucket is created on first use; with anonymousRead a new bucket gets a public read policy. An existing bucket keeps the policy it has, so an operator who tightened it by hand is not overruled.
func (*Storage) PutStream ¶
func (s *Storage) PutStream(ctx context.Context, bucket string, anonymousRead bool, objectPath, contentType string, r io.Reader, size int64) (string, error)
PutStream stores an object read from r, for files too large to hold in memory. A negative size streams an object of unknown length in parts.