Documentation ¶
Overview ¶
Package storage offers generic (cloud) storage drivers.
Directories ¶
Note that there are no mkdir/rmdir operations, although storage drivers should support subdirectories. Directory management is abstracted away in the backends that should attempt to purge empty directories.
Index ¶
- Variables
- func ExistError(op, path string) error
- func Glob(ctx context.Context, storage Storage, pattern string) (matches []string, err error)
- func NotExistError(op, path string) error
- func PermissonError(op, path string) error
- func Register(kind string, fn func() Opener)
- type Config
- type Opener
- type Storage
Constants ¶
This section is empty.
Variables ¶
ErrBadPattern indicates a pattern was malformed.
Common errors.
Functions ¶
func ExistError ¶ added in v1.0.0
ExistError returns an error indicating that the file already exists. The error will pass os.IsExist.
func Glob ¶
Glob returns the names of all files matching pattern or nil if there is no matching file. The pattern may describe hierarchical names such as /usr/*/bin/ed.
Glob ignores file system errors such as I/O errors reading directories. The only possible returned error is ErrBadPattern, when pattern is malformed.
The pattern syntax is:
pattern: { term } term: '*' matches any sequence of non-Separator characters '?' matches any single non-Separator character '[' [ '^' ] { character-range } ']' character class (must be non-empty) c matches character c (c != '*', '?', '\\', '[') '\\' c matches character c character-range: c matches character c (c != '\\', '-', ']') '\\' c matches character c lo '-' hi matches character c for lo <= c <= hi
func NotExistError ¶ added in v1.0.0
NotExistError returns an error indicating that a file doesn't exist. The error will pass os.IsNotExist.
func PermissonError ¶ added in v1.0.0
PermissonError returns an error indicating that there is a permission error accessing the file. The error will pass os.IsPermission.
Types ¶
type Config ¶
type Config struct { Type string `json:"type" yaml:"type"` Config map[string]interface{} `json:"config" yaml:"config"` }
Config for a storage backend.
type Opener ¶ added in v1.0.0
Opener can open a new Storage.
type Storage ¶
type Storage interface { // Name gives a description of the storage. Name() string // Close the storage. Close() error // Save a file to the storage. Save(ctx context.Context, name string, r io.Reader) error // Open a file from storage for reading. Open(ctx context.Context, name string) (io.ReadCloser, error) // Create a file in storage for writing. Create(ctx context.Context, name string) (io.WriteCloser, error) // Readdir reads directory contents. Readdir(ctx context.Context, name string) ([]os.FileInfo, error) // Stat a file in storage. Stat(ctx context.Context, name string) (os.FileInfo, error) // Remove a file from storage. Remove(ctx context.Context, name string) error }
Storage for named files. All paths in the supported storage use a backward slash ("/") as path separator.
Directories ¶
Path | Synopsis |
---|---|
Package all loads all supported storage drivers.
|
Package all loads all supported storage drivers. |
cmd
|
|
Package disk provides local disk storage.
|
Package disk provides local disk storage. |
Package ftp provides FTP storage.
|
Package ftp provides FTP storage. |
Package google provides Google Drive storage.
|
Package google provides Google Drive storage. |
internal
|
|
obscure
Package obscure contains the Obscure and Reveal commands
|
Package obscure contains the Obscure and Reveal commands |
Package oauth2 contains helper functions for provisioning OAuth2 tokens.
|
Package oauth2 contains helper functions for provisioning OAuth2 tokens. |
Package s3 provides S3 (and compatible) storage.
|
Package s3 provides S3 (and compatible) storage. |
Package sftp provides SFTP storage.
|
Package sftp provides SFTP storage. |
Package webdav provides WebDAV (and compatible) storage.
|
Package webdav provides WebDAV (and compatible) storage. |