Documentation ¶
Overview ¶
Package filestore provides a simple interface for managing a store of files, with local and remote store implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filestore ¶
type Filestore interface { // Get retrieves a file from the store and returns a read-only File // descriptor. The path is relative to the store root. File.Close should be // called as soon as the file is no longer in use. ErrFileNotFound is returned // if path does not exist. Get(ctx context.Context, path string) (File, error) // Insert inserts a file into the store. The destination path is relative to // the store root. Parent directories are created automatically if needed. If // dest already exists, the file is safely overwritten. Insert(ctx context.Context, src io.Reader, dest string) error // Remove permanently deletes the file from the store. The path is relative to // the store root. ErrFileNotFound is returned if path does not exist. Remove(ctx context.Context, path string) error // Close frees up any resources currently in use. Close() error }
type FilestoreLocal ¶
type FilestoreLocal struct { // Dir is the root directory for the filestore. Dir string // FileMode holds the permission bits given to new files. FilePerm fs.FileMode // DirMode holds the permission bits given to new directories. DirPerm fs.FileMode }
FilestoreLocal implements Filestore using a local directory.
func NewFilestoreLocal ¶
func NewFilestoreLocal(config ...LocalConfigFunc) (*FilestoreLocal, error)
NewFilestoreLocal creates a new FilestoreLocal initialized with the given root directory.
func (*FilestoreLocal) Close ¶
func (f *FilestoreLocal) Close() error
type LocalConfigFunc ¶
type LocalConfigFunc func(*FilestoreLocal)
func SetLocalDir ¶
func SetLocalDir(dir string) LocalConfigFunc
func SetLocalDirPerm ¶
func SetLocalDirPerm(perm fs.FileMode) LocalConfigFunc
func SetLocalFilePerm ¶
func SetLocalFilePerm(perm fs.FileMode) LocalConfigFunc
Click to show internal directories.
Click to hide internal directories.