Documentation ¶
Overview ¶
Package storage implements utilities to add/remove files from a filesystem. Typically used from a server or http.Handler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrAlreadyExists file already exists. ErrAlreadyExists = errors.New("file already exists") // ErrInvalidExtension invalid extension. ErrInvalidExtension = errors.New("invalid extension") )
Functions ¶
func Register ¶
Register registers a driver on the package. Typically called from driver implementations.
func ResolveContentType ¶
ResolveContentType resolves the content-type based on the extension of path.
Types ¶
type DangerDriver ¶
type DangerDriver interface { // Cleans out the container (bucket, space, etc.). EmptyContainer() error // DeleteContaineer empties the container, and deletes it. DeleteContainer() error }
DangerDriver interface to be implemented by storage drivers. Most providers in this package implement this interface, but it's delivered as a separate interface (hidden behind a type conversion) due to the permanent nature of these methods.
type Driver ¶
type Driver interface { // Open opens a connection and returns a Driver. Each implementation // should explain how to connect to it through its urlString. Open(url string) (Driver, error) Close() error // Accepts determines if this storage driver will allow ext. Accepts(ext string) bool // Path returns the root path of the storage driver. Path() string // NormalizePath returns the passed entries with the necessary prefix // e.g. driver.NormalizePath("path/to/file") == "/assets/path/to/file" NormalizePath(entries ...string) string // AddFile saves the contents of r to path. AddFile(r io.Reader, path string) (string, error) // GetFile returns an io.ReadCloser with the contents of the file. GetFile(path string) (io.ReadCloser, error) // RemoveFile removes the file on path from the driver (if found). RemoveFile(path string) error }
Driver interface to be implemented by storage drivers.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
internal
|
|
util
Package awsabs has dependency injected abstractions for AWS-S3 services.
|
Package awsabs has dependency injected abstractions for AWS-S3 services. |
providers
|
|
fs
Package fs implements a storage.Driver for a local filesystem.
|
Package fs implements a storage.Driver for a local filesystem. |
Click to show internal directories.
Click to hide internal directories.