storage

package
v0.0.0-...-db146dd Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DriverTypes Used for the CLI interface, to list all available driver types
	DriverTypes = []string{"local", "sftp"}
	// DriverFields Used for the CLI interface, to list all required fields for each driver type
	DriverFields = map[string][]string{
		"local": {"Name", "MaxSize", "RootPath"},
		"sftp":  {"Name", "MaxSize", "RootPath", "Ip", "Port", "Username", "Password"},
	}

	DriverMap = map[string]Driver{}
)

Functions

func InitialiseDriverMap

func InitialiseDriverMap()

Types

type Driver

type Driver interface {
	Started() bool
	Connect() error
	Disconnect() error
	UploadFile(file LocalFile) (RemoteFile, error)
	StreamFile(path string) (io.ReadCloser, error)
	DownloadFile(path string, targetPath string) error
	DeleteFile(path string) error
	ListFiles(path string) ([]string, error)
	GetFile(path string) ([]byte, error)
}

func GetDriver

func GetDriver(driverType string, config map[string]string) Driver

func GetDriverFromBucket

func GetDriverFromBucket(bucket database.StorageBucket) Driver

func GetInitialisedDriver

func GetInitialisedDriver(bucket database.StorageBucket) Driver

func NewLocalDriver

func NewLocalDriver(config map[string]string) Driver

func NewSFTPDRiver

func NewSFTPDRiver(config map[string]string) Driver

type LocalDriver

type LocalDriver struct {
	RootPath string
}

func (*LocalDriver) Connect

func (d *LocalDriver) Connect() error

func (*LocalDriver) DeleteFile

func (d *LocalDriver) DeleteFile(path string) error

func (*LocalDriver) Disconnect

func (d *LocalDriver) Disconnect() error

func (*LocalDriver) DownloadFile

func (d *LocalDriver) DownloadFile(path string, targetPath string) error

func (*LocalDriver) GetFile

func (d *LocalDriver) GetFile(path string) ([]byte, error)

func (*LocalDriver) ListFiles

func (d *LocalDriver) ListFiles(path string) ([]string, error)

func (*LocalDriver) Started

func (d *LocalDriver) Started() bool

func (*LocalDriver) StreamFile

func (d *LocalDriver) StreamFile(path string) (io.ReadCloser, error)

func (*LocalDriver) UploadFile

func (d *LocalDriver) UploadFile(file LocalFile) (RemoteFile, error)

type LocalFile

type LocalFile struct {
	Name   string
	Size   int
	Reader io.Reader
}

type RemoteFile

type RemoteFile struct {
	Name string
	Size int
	Path string
}

type SftpDriver

type SftpDriver struct {
	Username   string
	Password   string
	Ip         string
	Port       int
	RootPath   string
	Connection *sftp.Client
	IsStarted  bool
}

func (*SftpDriver) Connect

func (d *SftpDriver) Connect() error

func (*SftpDriver) DeleteFile

func (d *SftpDriver) DeleteFile(path string) error

func (*SftpDriver) Disconnect

func (d *SftpDriver) Disconnect() error

func (*SftpDriver) DownloadFile

func (d *SftpDriver) DownloadFile(path string, targetPath string) error

func (*SftpDriver) GetFile

func (d *SftpDriver) GetFile(path string) ([]byte, error)

func (*SftpDriver) ListFiles

func (d *SftpDriver) ListFiles(path string) ([]string, error)

func (*SftpDriver) Started

func (d *SftpDriver) Started() bool

func (*SftpDriver) StreamFile

func (d *SftpDriver) StreamFile(path string) (io.ReadCloser, error)

func (*SftpDriver) UploadFile

func (d *SftpDriver) UploadFile(file LocalFile) (RemoteFile, error)

Jump to

Keyboard shortcuts

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