storage

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternal      = errors.New("internal error")
	ErrAlreadyExists = errors.New("already exists")
	ErrNotFound      = errors.New("not found")
	ErrLimitExceeded = errors.New("limit exceeded")
	ErrListFailed    = errors.New("can't list")
	ErrCopyFailed    = errors.New("can't copy")
	ErrOpenFailed    = errors.New("can't open")
	ErrCreateFailed  = errors.New("can't create")
	ErrReadFailed    = errors.New("can't read")
	ErrWriteFailed   = errors.New("can't write")
	ErrCloseFailed   = errors.New("can't close")
	ErrRemoveFailed  = errors.New("can't remove")
	ErrRenameFailed  = errors.New("can't rename")
)

Error list of storage package

Functions

This section is empty.

Types

type FS

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

FS is main class for FS API

func (*FS) AppendFile

func (fs *FS) AppendFile(path string, data []byte) error

AppendFile is function that append data to an exist file

func (*FS) CopyFile

func (fs *FS) CopyFile(src, dst string) error

CopyFile is function that copies a file from src to dst If src and dst files exist, and are the same, then return success.

func (*FS) CreateDir

func (fs *FS) CreateDir(path string) error

CreateDir is function for create new directory if not exists

func (*FS) CreateFile

func (fs *FS) CreateFile(path string) error

CreateFile is function for create new file if not exists

func (*FS) DefPerm

func (l *FS) DefPerm() os.FileMode

func (*FS) GetInfo

func (fs *FS) GetInfo(path string) (os.FileInfo, error)

GetInfo is function that return file info

func (*FS) IsExist

func (fs *FS) IsExist(path string) bool

IsExist is function that return true if file exists

func (*FS) IsNotExist

func (fs *FS) IsNotExist(path string) bool

IsNotExist is function that return true if file not exists

func (*FS) ListDir

func (fs *FS) ListDir(path string) (map[string]os.FileInfo, error)

ListDir is function that return listing directory with filea info Return key in the map is relative path from input base path.

func (*FS) ListDirRec

func (fs *FS) ListDirRec(path string) (map[string]os.FileInfo, error)

ListDirRec is function that return listing directory with filea info Return key in the map is relative path from input base path.

func (*FS) MaxFileSize

func (l *FS) MaxFileSize() int64

func (*FS) MaxNumObjs

func (l *FS) MaxNumObjs() int64

func (*FS) MaxReadSize

func (l *FS) MaxReadSize() int64

func (*FS) ReadDir

func (fs *FS) ReadDir(path string) (map[string][]byte, error)

ReadDir is function that read all files in the directory

func (*FS) ReadDirRec

func (fs *FS) ReadDirRec(path string) (map[string][]byte, error)

ReadDirRec is function that recursive read all files in the directory

func (*FS) ReadFile

func (fs *FS) ReadFile(path string) ([]byte, error)

ReadFile is function that return the file data

func (*FS) Remove

func (fs *FS) Remove(path string) error

Remove is function that remove any exist object

func (*FS) RemoveDir

func (fs *FS) RemoveDir(path string) error

RemoveDir is function that remove an exist directory

func (*FS) RemoveFile

func (fs *FS) RemoveFile(path string) error

RemoveFile is function that remove an exist file

func (*FS) Rename

func (fs *FS) Rename(src, dst string) error

Rename is function that rename any exist object to new

func (*FS) SetDefPerm

func (l *FS) SetDefPerm(perm os.FileMode)

func (*FS) SetMaxFileSize

func (l *FS) SetMaxFileSize(max int64)

func (*FS) SetMaxNumObjs

func (l *FS) SetMaxNumObjs(max int64)

func (*FS) SetMaxReadSize

func (l *FS) SetMaxReadSize(max int64)

func (*FS) WriteFile

func (fs *FS) WriteFile(path string, data []byte) error

WriteFile is function that write (override) data to a file

type ILimits

type ILimits interface {
	DefPerm() os.FileMode
	SetDefPerm(perm os.FileMode)
	MaxFileSize() int64
	SetMaxFileSize(max int64)
	MaxReadSize() int64
	SetMaxReadSize(max int64)
	MaxNumObjs() int64
	SetMaxNumObjs(max int64)
}

ILimits is additional interface for limits control

type IStorage

type IStorage interface {
	ListDir(path string) (map[string]os.FileInfo, error)
	ListDirRec(path string) (map[string]os.FileInfo, error)
	GetInfo(path string) (os.FileInfo, error)
	IsExist(path string) bool
	IsNotExist(path string) bool
	ReadFile(path string) ([]byte, error)
	ReadDir(path string) (map[string][]byte, error)
	ReadDirRec(path string) (map[string][]byte, error)
	CreateDir(path string) error
	CreateFile(path string) error
	WriteFile(path string, data []byte) error
	AppendFile(path string, data []byte) error
	RemoveDir(path string) error
	RemoveFile(path string) error
	Remove(path string) error
	Rename(old, new string) error
	CopyFile(src, dst string) error
	ILimits
}

IStorage is main interface for using external storages

func NewFS

func NewFS() (IStorage, error)

NewFS is function that construct FS driver with IStorage

func NewS3

func NewS3(args ...string) (IStorage, error)

NewS3 is function that construct S3 driver with IStorage arg[0] - MINIO_ENDPOINT arg[1] - MINIO_ACCESS_KEY arg[2] - MINIO_SECRET_KEY arg[3] - MINIO_BUCKET_NAME

type S3

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

S3 is main class for S3 API

func (*S3) AppendFile

func (s *S3) AppendFile(path string, data []byte) error

AppendFile is function that append data to an exist file

func (*S3) CopyFile

func (s *S3) CopyFile(src, dst string) error

CopyFile is function that copies a file from src to dst

func (*S3) CreateDir

func (s *S3) CreateDir(path string) error

CreateDir is function for create new directory if not exists

func (*S3) CreateFile

func (s *S3) CreateFile(path string) error

CreateFile is function for create new file if not exists

func (*S3) DefPerm

func (l *S3) DefPerm() os.FileMode

func (*S3) GetInfo

func (s *S3) GetInfo(path string) (os.FileInfo, error)

GetInfo is function that return file info

func (*S3) IsExist

func (s *S3) IsExist(path string) bool

IsExist is function that return true if file exists

func (*S3) IsNotExist

func (s *S3) IsNotExist(path string) bool

IsNotExist is function that return true if file not exists

func (*S3) ListDir

func (s *S3) ListDir(path string) (map[string]os.FileInfo, error)

ListDir is function that return listing directory with filea info

func (*S3) ListDirRec

func (s *S3) ListDirRec(path string) (map[string]os.FileInfo, error)

ListDirRec is function that return listing directory with filea info

func (*S3) MaxFileSize

func (l *S3) MaxFileSize() int64

func (*S3) MaxNumObjs

func (l *S3) MaxNumObjs() int64

func (*S3) MaxReadSize

func (l *S3) MaxReadSize() int64

func (*S3) ReadDir

func (s *S3) ReadDir(path string) (map[string][]byte, error)

ReadDir is function that read all files in the directory

func (*S3) ReadDirRec

func (s *S3) ReadDirRec(path string) (map[string][]byte, error)

ReadDirRec is function that recursive read all files in the directory

func (*S3) ReadFile

func (s *S3) ReadFile(path string) ([]byte, error)

ReadFile is function that return the file data

func (*S3) Remove

func (s *S3) Remove(path string) error

Remove is function that remove any exist object

func (*S3) RemoveDir

func (s *S3) RemoveDir(path string) error

RemoveDir is function that remove an exist directory

func (*S3) RemoveFile

func (s *S3) RemoveFile(path string) error

RemoveFile is function that remove an exist file

func (*S3) Rename

func (s *S3) Rename(src, dst string) error

Rename is function that rename any exist object to new

func (*S3) SetDefPerm

func (l *S3) SetDefPerm(perm os.FileMode)

func (*S3) SetMaxFileSize

func (l *S3) SetMaxFileSize(max int64)

func (*S3) SetMaxNumObjs

func (l *S3) SetMaxNumObjs(max int64)

func (*S3) SetMaxReadSize

func (l *S3) SetMaxReadSize(max int64)

func (*S3) WriteFile

func (s *S3) WriteFile(path string, data []byte) error

WriteFile is function that write (override) data to a file

type S3FileInfo

type S3FileInfo struct {
	*minio.ObjectInfo
	// contains filtered or unexported fields
}

S3FileInfo is struct with interface os.FileInfo

func (*S3FileInfo) IsDir

func (si *S3FileInfo) IsDir() bool

IsDir is function that return true if it's directory

func (*S3FileInfo) ModTime

func (si *S3FileInfo) ModTime() time.Time

ModTime is function that return last modification time

func (*S3FileInfo) Mode

func (si *S3FileInfo) Mode() os.FileMode

Mode is function that return file mod structure

func (*S3FileInfo) Name

func (si *S3FileInfo) Name() string

Name is function that return file name

func (*S3FileInfo) Size

func (si *S3FileInfo) Size() int64

Size is function that return file size

func (*S3FileInfo) Sys

func (si *S3FileInfo) Sys() interface{}

Sys is function that return dummy info

Jump to

Keyboard shortcuts

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