cloud

package
v0.0.0-...-1c5c016 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFolderNotExists       = errors.New("folder not exists")
	ErrFolderParentNotExists = errors.New("parent not exists")
)
View Source
var (
	ErrFileNotExists = errors.New("file not exists")
)

Functions

This section is empty.

Types

type Cloud

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

func New

func New(repository *Repository) *Cloud

func (Cloud) File

func (c Cloud) File() *File

func (Cloud) Folder

func (c Cloud) Folder() *Folder

type File

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

func (File) Copy

func (f File) Copy(ctx context.Context, fcopy types.CopyFile) (created types.File, err error)

func (File) Download

func (f File) Download(ctx context.Context, id string) (types.DownloadFile, error)

func (File) Find

func (f File) Find(ctx context.Context, folderID string, sort types.Sort) ([]types.File, error)

func (File) MarkDelete

func (f File) MarkDelete(ctx context.Context, id []string) error

func (File) Move

func (f File) Move(ctx context.Context, move types.Move) error

func (File) Rename

func (f File) Rename(ctx context.Context, file types.File) (types.File, error)

func (File) Upload

func (f File) Upload(ctx context.Context, files []types.File) ([]types.Upload, error)

type FileRepository

type FileRepository interface {
	// IsExists check file exists by id (file id)
	IsExists(ctx context.Context, id string) (ok bool, err error)
	// GetByFolderID return files info by folderID (folder binding)
	GetByFolderID(ctx context.Context, folderID string, sort types.Sort) ([]types.File, error)
	// UpdateName - update file name where file id
	// return updated file info
	UpdateName(ctx context.Context, id, name string) (updated types.File, err error)
	// UpdateFolderID - update files folder id by files id
	UpdateFolderID(ctx context.Context, id []string, folderID string) error
	// Open opening file by name with full file information like: file.txt,
	// without full dir path
	// use with file information id like: 4d2e16db-3bb4-430d-b7e6-6844da203595.pdf
	Open(ctx context.Context, name string) (io.ReadCloser, error)
	// Copy copied some file
	// dst is a destination file name with file information (with type)
	// src is a source file name with file information (with type)
	Copy(ctx context.Context, dst, src string) (err error)
	// GetByID getting file by id
	GetByID(ctx context.Context, id string) (ff types.File, err error)
	// MarkDelete is a safety delete file info
	// don't delete some file by mark delete
	MarkDelete(ctx context.Context, id []string) error
}

type Folder

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

func (Folder) Create

func (f Folder) Create(ctx context.Context, folder types.Folder) (types.Folder, error)

func (Folder) Find

func (f Folder) Find(ctx context.Context, parentID *string, sort types.Sort) ([]*types.Folder, error)

func (Folder) Folder

func (f Folder) Folder(ctx context.Context, id string) (types.Folder, error)

func (Folder) Update

func (f Folder) Update(ctx context.Context, folder types.Folder) (types.Folder, error)

type FolderRepository

type FolderRepository interface {
	// Get getting folder by id
	Get(ctx context.Context, id string) (*types.Folder, error)
	// GetByParent recursive getting folders directory where parent id
	// if parent id is nil, then return root directory.
	// sort is param to sorting folders tree
	GetByParent(ctx context.Context, parentID *string, sort types.Sort) (folders []*types.Folder, err error)
	// Create - create folder and return created folder
	Create(ctx context.Context, folder types.Folder) (types.Folder, error)
	// ExistsByID check exists folder where id return ok if folder exists
	// and return false if file is not exists
	ExistsByID(ctx context.Context, id string) (bool, error)
	// ExistsByParentIDName exists file/files by parent id and name
	// if parent id is nil, then check that name in root directory is exits
	ExistsByParentIDName(ctx context.Context, parentID *string, name string) (bool, error)
	// Update - update folder where id and return updated folder
	Update(ctx context.Context, folder types.Folder) (types.Folder, error)
	// Delete recursive remove folder and him directory folders like `bash: rm -r`
	Delete(ctx context.Context, id string) error
}

type RemoverFile

type RemoverFile interface {
	RemoveFile(ctx context.Context, name string) error
}

type RemoverMeta

type RemoverMeta interface {
	RemoveMeta(ctx context.Context, id string) error
}

type Repository

type Repository struct {
	File   FileRepository
	Folder FolderRepository
	Saver  Saver
}

type Saver

type Saver interface {
	SaverRemoverMeta
	SaverRemoverFile
}

func NewSaver

func NewSaver(meta SaverRemoverMeta, file SaverRemoverFile) Saver

type SaverFile

type SaverFile interface {
	SaveFile(ctx context.Context, file types.File) error
}

type SaverMeta

type SaverMeta interface {
	SaveMeta(ctx context.Context, file types.File) (types.File, error)
}

type SaverRemoverFile

type SaverRemoverFile interface {
	SaverFile
	RemoverFile
}

type SaverRemoverMeta

type SaverRemoverMeta interface {
	SaverMeta
	RemoverMeta
}

Directories

Path Synopsis
repository

Jump to

Keyboard shortcuts

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