driver

package
v0.0.0-...-c590095 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFolder

func ExtractFolder(AbstractDriverFiles []AbstractDriverFile, extractFolder string)

func GetThumb

func GetThumb(AbstractDriverFile AbstractDriverFile) (thumb string, ok bool)

func GetUrl

func GetUrl(AbstractDriverFile AbstractDriverFile) (url string, ok bool)

func SortFiles

func SortFiles(AbstractDriverFiles []AbstractDriverFile, orderBy, orderDirection string)

func WrapAbstractDriverFilesName

func WrapAbstractDriverFilesName(AbstractDriverFiles []AbstractDriverFile)

Types

type AbstractDriverFile

type AbstractDriverFile interface {
	GetSize() int64
	GetName() string
	ModTime() time.Time
	IsDir() bool

	// The internal information of the driver.
	// If you want to use it, please understand what it means
	GetID() string
	GetPath() string
}

func UnwrapAbstractDriverFile

func UnwrapAbstractDriverFile(AbstractDriverFile AbstractDriverFile) AbstractDriverFile

func WrapAbstractDriverFileName

func WrapAbstractDriverFileName(AbstractDriverFiles AbstractDriverFile) AbstractDriverFile

type AbstractDriverFileMerge

type AbstractDriverFileMerge struct {
	// contains filtered or unexported fields
}

func NewAbstractDriverFileMerge

func NewAbstractDriverFileMerge() *AbstractDriverFileMerge

Merge

func (*AbstractDriverFileMerge) InitHideReg

func (om *AbstractDriverFileMerge) InitHideReg(hides string)

func (*AbstractDriverFileMerge) Merge

func (om *AbstractDriverFileMerge) Merge(AbstractDriverFiles []AbstractDriverFile, AbstractDriverFiles_ ...AbstractDriverFile) []AbstractDriverFile

func (*AbstractDriverFileMerge) Reset

func (om *AbstractDriverFileMerge) Reset()

type AbstractDriverFileUnwrap

type AbstractDriverFileUnwrap interface {
	Unwrap() AbstractDriverFile
}

type AbstractDriverFileWrapName

type AbstractDriverFileWrapName struct {
	Name string
	AbstractDriverFile
}

func (*AbstractDriverFileWrapName) GetName

func (o *AbstractDriverFileWrapName) GetName() string

func (*AbstractDriverFileWrapName) Unwrap

type Additional

type Additional interface{}

type Config

type Config struct {
	Name              string `json:"name"`
	LocalSort         bool   `json:"local_sort"`
	OnlyLocal         bool   `json:"only_local"`
	OnlyProxy         bool   `json:"only_proxy"`
	NoCache           bool   `json:"no_cache"`
	NoUpload          bool   `json:"no_upload"`
	NeedMs            bool   `json:"need_ms"` // if need get message from user, such as validate code
	DefaultRoot       string `json:"default_root"`
	CheckStatus       bool   `json:"-"`
	Alert             string `json:"alert"` //info,success,warning,danger
	NoOverwriteUpload bool   `json:"-"`
}

func (Config) MustProxy

func (c Config) MustProxy() bool

type Copy

type Copy interface {
	Copy(ctx context.Context, srcObj, dstDir AbstractDriverFile) error
}

type Driver

type Driver interface {
	Meta
	Reader
	Put
	Mkdir
	Move
	Rename
	Copy
	Remove
}

type DriverFile

type DriverFile struct {
	ID       string
	Path     string
	Name     string
	Size     int64
	Modified time.Time
	IsFolder bool
}

func (*DriverFile) GetID

func (o *DriverFile) GetID() string

func (*DriverFile) GetName

func (o *DriverFile) GetName() string

func (*DriverFile) GetPath

func (o *DriverFile) GetPath() string

func (*DriverFile) GetSize

func (o *DriverFile) GetSize() int64

func (*DriverFile) IsDir

func (o *DriverFile) IsDir() bool

func (*DriverFile) ModTime

func (o *DriverFile) ModTime() time.Time

func (*DriverFile) SetPath

func (o *DriverFile) SetPath(id string)

type DriverFileThumb

type DriverFileThumb struct {
	DriverFile
	Thumbnail
}

type DriverFileThumbURL

type DriverFileThumbURL struct {
	DriverFile
	Thumbnail
	Url
}

type DriverFileURL

type DriverFileURL struct {
	DriverFile
	Url
}

type FileStreamer

type FileStreamer interface {
	io.ReadCloser
	AbstractDriverFile
	GetMimetype() string
	SetReadCloser(io.ReadCloser)
	NeedStore() bool
	GetReadCloser() io.ReadCloser
	GetOld() AbstractDriverFile
}

type FsOtherArgs

type FsOtherArgs struct {
	Path   string      `json:"path" form:"path"`
	Method string      `json:"method" form:"method"`
	Data   interface{} `json:"data" form:"data"`
}

type GetRooter

type GetRooter interface {
	GetRoot(ctx context.Context) (AbstractDriverFile, error)
}

type Getter

type Getter interface {
	// Get file by path, the path haven't been joined with root path
	Get(ctx context.Context, path string) (AbstractDriverFile, error)
}
type Link struct {
	URL        string         `json:"url"`
	Header     http.Header    `json:"header"` // needed header
	Data       io.ReadCloser  // return file reader directly
	Status     int            // status maybe 200 or 206, etc
	FilePath   *string        // local file, return the filepath
	Expiration *time.Duration // url expiration time
}

type LinkArgs

type LinkArgs struct {
	IP     string
	Header http.Header
	Type   string
}

type ListArgs

type ListArgs struct {
	ReqPath string
}

type Meta

type Meta interface {
	Config() Config
	// GetStorage just get raw storage, no need to implement, because model.Storage have implemented
	// SetStorage(model.Storage)
	// GetAddition Additional is used for unmarshal of JSON, so need return pointer
	GetAddition() Additional
	// Init If already initialized, drop first
	Init(ctx context.Context) error
	Drop(ctx context.Context) error
}

type Mkdir

type Mkdir interface {
	MakeDir(ctx context.Context, parentDir AbstractDriverFile, dirName string) error
}

type Move

type Move interface {
	Move(ctx context.Context, srcObj, dstDir AbstractDriverFile) error
}

type OtherArgs

type OtherArgs struct {
	AbstractDriverFile AbstractDriverFile
	Method             string
	Data               interface{}
}

type Progress

type Progress struct {
	Total int64
	Done  int64
	// contains filtered or unexported fields
}

func NewProgress

func NewProgress(total int64, up UpdateProgress) *Progress

func (*Progress) Write

func (p *Progress) Write(b []byte) (n int, err error)

type Put

type Put interface {
	Put(ctx context.Context, dstDir AbstractDriverFile, stream FileStreamer, up UpdateProgress) error
}

type Reader

type Reader interface {
	// List files in the path
	// if identify files by path, need to set ID with path,like path.Join(dir.GetID(), obj.GetName())
	// if identify files by id, need to set ID with corresponding id
	List(ctx context.Context, dir AbstractDriverFile, args ListArgs) ([]AbstractDriverFile, error)
	// Link get url/filepath/reader of file
	Link(ctx context.Context, file AbstractDriverFile, args LinkArgs) (*Link, error)
}

type Remove

type Remove interface {
	Remove(ctx context.Context, obj AbstractDriverFile) error
}

type Rename

type Rename interface {
	Rename(ctx context.Context, srcObj AbstractDriverFile, newName string) error
}

type RootPath

type RootPath struct {
	RootFolderPath string `json:"root_folder_path"`
}

func (RootPath) GetRootPath

func (r RootPath) GetRootPath() string

func (*RootPath) SetRootPath

func (r *RootPath) SetRootPath(path string)

type SetPath

type SetPath interface {
	SetPath(path string)
}

type Thumb

type Thumb interface {
	Thumb() string
}

type Thumbnail

type Thumbnail struct {
	Thumbnail string
}

func (Thumbnail) Thumb

func (t Thumbnail) Thumb() string

type URL

type URL interface {
	URL() string
}

type UpdateProgress

type UpdateProgress func(percentage int)

type Url

type Url struct {
	Url string
}

func (Url) URL

func (w Url) URL() string

Jump to

Keyboard shortcuts

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