model

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: MIT Imports: 7 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ImageExtensions contains extensions of Image
	ImageExtensions = map[string]bool{".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".svg": true, ".tiff": true}
	// PdfExtensions contains extensions of Pdf
	PdfExtensions = map[string]bool{".pdf": true}
	// VideoExtensions contains extensions of Video
	VideoExtensions = map[string]string{".mp4": "video/mp4", ".mov": "video/quicktime", ".avi": "video/x-msvideo"}
)

Functions

func Dirname

func Dirname(name string) string

Dirname ensures given name is a dirname, with a trailing slash

func ErrNotExist

func ErrNotExist(err error) error

ErrNotExist create a NotExist error

func IsNotExist

func IsNotExist(err error) bool

IsNotExist checks if error match a not found

Types

type Item

type Item struct {
	Date     time.Time `json:"date"`
	Name     string    `json:"name"`
	Pathname string    `json:"pathname"`
	IsDir    bool      `json:"isDir"`
	Size     int64     `json:"size"`
}

Item describe item on a storage provider

func (Item) Dir

func (s Item) Dir() string

Dir return the nearest directory (self of parent)

func (Item) Extension

func (s Item) Extension() string

Extension gives extensions of item

func (Item) IsImage

func (s Item) IsImage() bool

IsImage determine if item if an image

func (Item) IsPdf

func (s Item) IsPdf() bool

IsPdf determine if item if a pdf

func (Item) IsVideo

func (s Item) IsVideo() bool

IsVideo determine if item if a video

type Storage

type Storage interface {
	Enabled() bool
	Name() string
	WithIgnoreFn(ignoreFn func(Item) bool) Storage
	Path(pathname string) string
	Info(pathname string) (Item, error)
	List(pathname string) ([]Item, error)
	WriterTo(pathname string) (io.WriteCloser, error)
	ReaderFrom(pathname string) (io.ReadSeekCloser, error)
	Walk(pathname string, walkFn func(Item) error) error
	CreateDir(pathname string) error
	Rename(oldName, newName string) error
	Remove(pathname string) error
	UpdateDate(pathname string, date time.Time) error
}

Storage describe action on a storage provider

Jump to

Keyboard shortcuts

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