Documentation ¶
Overview ¶
Package filestore stores files in various types of storage systems.
Index ¶
- type Config
- type File
- type Interface
- type Local
- func (l *Local) Delete(ctx context.Context, relPath string) error
- func (l *Local) Get(ctx context.Context, relPath string) (*File, io.ReadCloser, error)
- func (l *Local) Head(ctx context.Context, relPath string) (*File, error)
- func (l *Local) List(ctx context.Context, relPath string, recursive bool) (<-chan *File, <-chan error)
- func (l *Local) Put(ctx context.Context, relPath string, r io.Reader) (*File, error)
- func (l *Local) Type() string
- type LocalConfig
- type S3
- func (s *S3) Delete(ctx context.Context, relPath string) error
- func (s *S3) Get(ctx context.Context, relPath string) (*File, io.ReadCloser, error)
- func (s *S3) Head(ctx context.Context, relPath string) (*File, error)
- func (s *S3) List(ctx context.Context, relPath string, recursive bool) (<-chan *File, <-chan error)
- func (s *S3) Put(ctx context.Context, relPath string, reader io.Reader) (*File, error)
- func (s *S3) Type() string
- type S3Config
- type S3Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.8.10
type Config struct { // Type is the type of file store to use: "", "local", "s3" Type string // Local configures storing files in local filesystem. Local LocalConfig // S3 configures storing files in S3. S3 S3Config }
Config configures a particular file store implementation.
type File ¶
type File struct { // Modified it the last modification time. Modified time.Time // Path is the path to the file relative to the root of the file store. // Path separators are always slash ('/') characters. Path string // Size if the number of bytes of data in the file. Size int64 // URL is a URL where the file can be retrieved from, if available. URL string }
File contains information about a stored file.
type Interface ¶
type Interface interface { // Delete removes the specified file from storage. Delete(ctx context.Context, path string) error // Get retrieves the specified file from storage. Returns fs.ErrNotExist if // file is not count. Get(ctx context.Context, path string) (*File, io.ReadCloser, error) // Head gets information about the specified file in storage. Returns // fs.ErrNotExist if file is not count. Head(ctx context.Context, path string) (*File, error) // List returns a series of *File on the first channel returned. If an // error occurs, the first channel is closed and the error is returned on // the second channel. List(ctx context.Context, path string, recursive bool) (<-chan *File, <-chan error) // Put writes a file to storage. A nil reader creates an empty file. Put(ctx context.Context, path string, reader io.Reader) (*File, error) // Type returns the file store type. Type() string }
Interface is the interface supported by all file store implementations. All Path arguments are relative to the root of the file store and always use slash ('/') characters.
func MakeFilestore ¶ added in v0.8.10
MakeFilestore creates a new storage system of the configured type.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a file store that stores files in the local file system.
type LocalConfig ¶ added in v0.8.10
type LocalConfig struct { // BasePath is the filesystem directory where files are stored. BasePath string }
type S3 ¶
type S3 struct {
// contains filtered or unexported fields
}
S3 is a file store that stores files in AWS S3.
The region is set by environment variable and authentication is done by assuming a role, which is handled by infrastructure.
type S3Config ¶ added in v0.8.10
type S3Config struct { BucketName string // ## Optional Overrides ## // // These values are generally set by the environment and should only be // provided when necessary to override values from the environment, or when // the environment is not configured. Endpoint string Region string AccessKey string SecretKey string }