storage

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2020 License: Apache-2.0 Imports: 3 Imported by: 68

Documentation

Overview

Package storage defines Storage API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthTracker added in v0.5.0

type AuthTracker interface {
	//IsAuthChanged return true if auth has changed
	IsAuthChanged(ctx context.Context, baseURL string, options []Option) bool
}

AuthTracker represents auth change tracker

type Authenticator

type Authenticator interface {
	//Auth authenticate URL scheme with authentication option
	Auth(baseURL string, option ...Option)
}

Authenticator represents an authennticator

type BatchUploader

type BatchUploader interface {
	//Uploader returns upload handler, and upload closer for batch upload or error
	Uploader(ctx context.Context, URL string, options ...Option) (Upload, io.Closer, error)
}

BatchUploader represents a batch uploader

type Checker

type Checker interface {
	//Exists returns true if resource exists
	Exists(ctx context.Context, URL string, options ...Option) (bool, error)
}

Checker represents abstraction that check if resource exists

type Copier

type Copier interface {
	//Copy copies source to dest
	Copy(ctx context.Context, sourceURL, destURL string, options ...Option) error
}

Copier represents an asset copier

type Creator

type Creator interface {
	//CreateBucket creates a bucket
	Create(ctx context.Context, URL string, mode os.FileMode, isDir bool, options ...Option) error
}

Creator represents a creator

type Deleter

type Deleter interface {
	//Delete removes passed in storage object
	Delete(ctx context.Context, URL string, options ...Option) error
}

Deleter represents a deleter

type Downloader

type Downloader interface {
	//Download returns reader for downloaded storage object
	Download(ctx context.Context, object Object, options ...Option) (io.ReadCloser, error)

	//Download returns reader for downloaded storage object
	DownloadWithURL(ctx context.Context, URL string, options ...Option) (io.ReadCloser, error)
}

Downloader represents a downloader

type Getter added in v0.9.0

type Getter interface {
	//List returns a list of object for supplied url
	Object(ctx context.Context, URL string, options ...Option) (Object, error)
}

Getter represents asset getter

type Lister

type Lister interface {
	//List returns a list of object for supplied url
	List(ctx context.Context, URL string, options ...Option) ([]Object, error)
}

Lister represents asset lister

type Manager

type Manager interface {
	Lister
	Downloader
	Uploader
	Deleter
	Creator
	io.Closer
	Scheme() string
}

Manager represents storage manager

type Mover

type Mover interface {
	//Move moves source to dest
	Move(ctx context.Context, sourceURL, destURL string, options ...Option) error
}

Mover represents an asset mover

type Object

type Object interface {
	os.FileInfo
	//URL return storage url
	URL() string

	//Wrap wraps source storage object
	Wrap(source interface{})
	//Unwrap unwraps source storage object into provided target.
	Unwrap(target interface{}) error
}

Object represents a storage object

type OnVisit

type OnVisit func(ctx context.Context, baseURL string, parent string, info os.FileInfo, reader io.Reader) (toContinue bool, err error)

OnVisit represents on location visit handler

type Option

type Option interface{}

Option represents generic service operation option

func NewOptions

func NewOptions(options []Option, extraOptions ...Option) []Option

NewOptions returns new options

type Options

type Options []Option

Options represents options

type Sizer added in v0.6.0

type Sizer interface {
	Size() int64
}

Sizer represents abstraction returing a size

type Storager

type Storager interface {
	io.Closer

	//Exists returns true if location exists
	Exists(ctx context.Context, location string, options ...Option) (bool, error)

	//List lists location assets
	List(ctx context.Context, location string, options ...Option) ([]os.FileInfo, error)

	//Get returns a file info for supplied location
	Get(ctx context.Context, location string, options ...Option) (os.FileInfo, error)

	//Download feches content for supplied location
	Download(ctx context.Context, location string, options ...Option) (io.ReadCloser, error)

	//Upload uploads
	Upload(ctx context.Context, destination string, mode os.FileMode, reader io.Reader, options ...Option) error

	//Create create file or directory
	Create(ctx context.Context, destination string, mode os.FileMode, reader io.Reader, isDir bool, options ...Option) error

	//Delete deletes locations
	Delete(ctx context.Context, location string, options ...Option) error
}

Storager represents path oriented storage service

type StoragerAuthTracker added in v0.5.0

type StoragerAuthTracker interface {

	//FilterAuthOptions filters auth options
	FilterAuthOptions(option []Option) []Option

	//IsAuthChanged return true if auth has changes
	IsAuthChanged(authOptions []Option) bool
}

StoragerAuthTracker represents auth manager

type Upload

type Upload func(ctx context.Context, parent string, info os.FileInfo, reader io.Reader) error

Upload uploads content

type Uploader

type Uploader interface {
	//Upload uploads provided reader content for supplied storage object.
	Upload(ctx context.Context, URL string, mode os.FileMode, reader io.Reader, options ...Option) error
}

Uploader represents an uploader

type Walker

type Walker interface {
	//Walk traverses URL and calls handler on all file or folder
	Walk(ctx context.Context, URL string, handler OnVisit, options ...Option) error
}

Walker represents abstract storage walker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL