Documentation ¶
Overview ¶
Package storage provides a methods and interfaces to access various storage systems and objects
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotExist is returned when a path does not exist ErrNotExist = errors.New("does not exist") // ErrCouldNotSeekFile is returned when a file could not be seeked ErrCouldNotSeekFile = errors.New("could not seek file") // ErrCouldNotReadFile is returned when a file could not be read ErrCouldNotReadFile = errors.New("could not read file") // ErrCouldNotWriteFile is returned when a file could not be written ErrCouldNotWriteFile = errors.New("could not write file") // ErrCouldNotDetectContentType is returned when a content type could not be detected ErrCouldNotDetectContentType = errors.New("could not detect content type") )
Functions ¶
func ComputeChecksum ¶
func ComputeChecksum(data io.ReadSeeker) (string, error)
ComputeChecksum calculates the MD5 checksum for the provided data. It expects that the passed io object will be seeked to its beginning and will seek back to the beginning after reading its content
func DetectContentType ¶
func DetectContentType(data io.ReadSeeker) (string, error)
DetectContentType leverages http.DetectContentType to identify the content type of the provided data. It expects that the passed io object will be seeked to its beginning and will seek back to the beginning after reading its content
func UnmarshalTo ¶
func UnmarshalTo(body io.ReadCloser, to interface{}) error
Unmarshals the content of the given body and stores it in the provided pointer
func UnmarshalToRawMessages ¶
func UnmarshalToRawMessages(body io.ReadCloser) ([]json.RawMessage, error)
unmarshalToRawMessages unmarshals the content of the given body and stores it in a juicy slice of json.RawMessage
Types ¶
type Stat ¶
Stat contains metadata about content stored in storage size and last modified time aren't fetched every time for lower processing overhead
type Storage ¶
type Storage interface { // Delete deletes the content at the given path Delete(ctx context.Context, path string) error // FileSystem returns the underlying filesystem FileSystem() *afero.Afero // Open opens a reader for the content at the given path Open(ctx context.Context, path string) (io.ReadCloser, error) // OpenWithStat opens a reader for the content at the given path and returns the metadata OpenWithStat(ctx context.Context, path string) (io.ReadCloser, *Stat, error) // Save saves content to path Save(ctx context.Context, content io.Reader, path string) error // Stat returns path metadata Stat(ctx context.Context, path string) (*Stat, error) // Tags returns the tags for the given path Tags(string) (map[string]string, error) // TempFileSystem returns a temporary filesystem TempFileSystem() *afero.Afero }
Storage is the package storage interface wrapper for absctracting the various storage backends
Directories ¶
Path | Synopsis |
---|---|
Package fs provides a storage implementation for the local filesystem
|
Package fs provides a storage implementation for the local filesystem |
Package gcs provides a storage implementation for GCS
|
Package gcs provides a storage implementation for GCS |
Package s3 provides a storage implementation for S3
|
Package s3 provides a storage implementation for S3 |