storage

package
v0.0.0-...-7af3d7a Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: GPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Test_email    = "losangeles971@gmail.com"
	Test_password = "losangeles971@gmail.com"
)
View Source
const (
	KIRINUKI_TMP = "KIRINUKI_TMP"
)
View Source
const (
	TEMP_STORAGE = "temp"
)

Variables

This section is empty.

Functions

func CleanTestEnv

func CleanTestEnv()

func CreateFile

func CreateFile(sFile string, size int) error

func DeleteLocalFile

func DeleteLocalFile(filename string)

func GetFileHash

func GetFileHash(filename string) (string, error)

func GetFilename

func GetFilename(size int) string

func GetHash

func GetHash(data []byte) string

func GetRndBytes

func GetRndBytes(size int) []byte

func GetTmp

func GetTmp() string

GetTmp: it returns the local temporary directory The local temporary directory is always necessary, since it is used to split e rebuild Kirinuki files.

func SetTestEnv

func SetTestEnv()

Types

type MultiStorage

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

MultiStorage: it allows to deal with all defined storage targets (upload, download, delete, ...)

func NewMultiStorage

func NewMultiStorage(opts ...MultiStorageOption) (*MultiStorage, error)

NewStorageMap creates a new StorageMap (empty or populated depending on the options)

func (*MultiStorage) Add

func (m *MultiStorage) Add(name string, def StorageDefinition) error

Add: it allows to manually add a storage target defined by ci

func (*MultiStorage) AddLocal

func (m *MultiStorage) AddLocal(name string, base string) error

func (*MultiStorage) Download

func (m *MultiStorage) Download(sName string, name string, filename string) (string, error)

func (*MultiStorage) Exist

func (m *MultiStorage) Exist(name string) bool

func (*MultiStorage) Get

func (m *MultiStorage) Get(sName string, name string) ([]byte, error)

func (*MultiStorage) LoadByJSON

func (m *MultiStorage) LoadByJSON(data []byte) error

func (*MultiStorage) Names

func (m *MultiStorage) Names() []string

Names: it returns the list of storage targets' names

func (*MultiStorage) Put

func (m *MultiStorage) Put(sName string, name string, data []byte) error

func (*MultiStorage) Size

func (m *MultiStorage) Size() int

func (*MultiStorage) Upload

func (m *MultiStorage) Upload(sName string, filename string, name string) error

type MultiStorageOption

type MultiStorageOption func(*MultiStorage) error

type SFTP

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

func NewSFTP

func NewSFTP(name string, cfg map[string]string) SFTP

func (SFTP) Download

func (s SFTP) Download(name string, filename string) (string, error)

func (SFTP) Get

func (s SFTP) Get(filename string) ([]byte, error)

Get returns a file (if exist) from the storage target

func (SFTP) Name

func (s SFTP) Name() string

func (SFTP) Put

func (s SFTP) Put(filename string, data []byte) error

Put saves a file to the storage target

func (SFTP) Upload

func (s SFTP) Upload(filename string, name string) error

type Storage

type Storage interface {
	Name() string
	Get(name string) ([]byte, error)
	Put(name string, data []byte) error
	Download(name string, filename string) (string, error) // save a file from target storage locally and computing the hash
	Upload(filename string, name string) error
}

Storage defines the interface of a generic storage target

func NewStowStorage

func NewStowStorage(name string, def StorageDefinition) (Storage, error)

type StorageDefinition

type StorageDefinition struct {
	Type string            `yaml:"type" json:"type"`
	Cfg  map[string]string `yaml:"config" json:"config"` // configuration parameters
}

StorageDefinition defines a specific storage target

type StorageDefinitions

type StorageDefinitions struct {
	Map map[string]StorageDefinition `yaml:"map" json:"map"`
}

StorageDefinitions contains a list of defined storage targets

type StowStorage

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

func (StowStorage) Download

func (s StowStorage) Download(name string, filename string) (string, error)

func (StowStorage) Get

func (s StowStorage) Get(name string) ([]byte, error)

Get returns a file (if exist) from the storage target

func (StowStorage) Name

func (s StowStorage) Name() string

func (StowStorage) Put

func (s StowStorage) Put(name string, data []byte) error

Put saves a file to the storage target

func (StowStorage) Upload

func (s StowStorage) Upload(filename string, name string) error

type StreamHash

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

func NewStreamHash

func NewStreamHash(r io.Reader) StreamHash

func (StreamHash) GetHash

func (s StreamHash) GetHash() string

func (StreamHash) GetReader

func (s StreamHash) GetReader() io.Reader

type TestLocalMultistorage

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

func NewTestLocalMultistorage

func NewTestLocalMultistorage(tDir string) *TestLocalMultistorage

NewLocalMultistorage: it creates a multistorage for testing purpose. This multistorage only uses local filesystem by means of a single Local Storage Target

func (*TestLocalMultistorage) Clean

func (tsm *TestLocalMultistorage) Clean()

func (*TestLocalMultistorage) GetMultiStorage

func (tsm *TestLocalMultistorage) GetMultiStorage() *MultiStorage

Jump to

Keyboard shortcuts

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