storage

package module
v0.0.0-...-40aff7f Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: MIT Imports: 19 Imported by: 0

README

Storage

storage is a Go library inspired by Laravel File Storage build on top of Rclone. Laravel provides a powerful filesystem abstraction thanks to the wonderful Flysystem PHP package by Frank de Jonge. So after I switched programming language to Golang, I want to have also something like file storage library for use in Golang, there is a wonderful tool called Rclone, Rclone support a long list of providers, I'm gonna use Rclone as file system core lib.

Installation

Installation is done using the go get command:

go get github.com/shareed2k/storage

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigNotFound = errors.New("config not found")
)

Functions

func AddDiskConfig

func AddDiskConfig(name string, config DiskConfig)

Types

type DiskConfig

type DiskConfig struct {
	Driver        string
	Root          string
	URL           string
	BackendConfig map[string]string
	Timeout       time.Duration
}

func (DiskConfig) Get

func (c DiskConfig) Get(key string) (value string, ok bool)

type Storage

type Storage interface {
	Size(path string) int64
	Exists(path string) bool
	Hash(path string) string
	Delete(paths ...string) error
	URL(path string) (string, error)
	MakeDirectory(path string) error
	Get(name string) (fs.File, error)
	DeleteDirectory(path string) error
	LastModified(path string) time.Time
	AllDirectories(path string) []string
	AllFiles(path string) (files fs.Files)
	Files(path string, recursive ...bool) fs.Files
	Directories(path string, recursive ...bool) fs.Dirs
	TemporaryURL(path string, expire time.Duration) (string, error)
	Put(path string, in io.ReadCloser, metadata ...*fs.HTTPOption) (fs.File, error)
	PutFile(dir string, in io.ReadCloser, metadata ...*fs.HTTPOption) (fs.File, error)
}

Storage _

func Disk

func Disk(name string) (Storage, error)

Disk _

func WithCacheDisk

func WithCacheDisk(name string, store cache.Store) (Storage, error)

WithCacheDisk _

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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