Documentation ¶
Index ¶
- Constants
- Variables
- func CopyFile(dest Exchanger, destName string, source Exchanger, sourceName string) error
- func LockFile(e Exchanger, name string, span time.Duration) (uint64, error)
- func ReadFile(e Exchanger, name string) ([]byte, error)
- func ReadJSON(e Exchanger, name string, v any, hash hash.Hash) error
- func S3ToUrl(c S3Config) string
- func ToUrl(config SFTPConfig) string
- func UnlockFile(e Exchanger, name string, id uint64)
- func WriteFile(e Exchanger, name string, data []byte) error
- func WriteJSON(e Exchanger, name string, v any, hash hash.Hash) error
- type Config
- type Exchanger
- type ListOption
- type Local
- func (l *Local) Close() error
- func (l *Local) Delete(name string) error
- func (l *Local) Read(name string, rang *Range, dest io.Writer) error
- func (l *Local) ReadDir(dir string, opts ListOption) ([]fs.FileInfo, error)
- func (l *Local) Rename(old, new string) error
- func (l *Local) Stat(name string) (os.FileInfo, error)
- func (l *Local) String() string
- func (l *Local) Touched(name string) bool
- func (l *Local) Write(name string, source io.Reader) error
- type LocalConfig
- type Range
- type S3
- func (s *S3) Close() error
- func (s *S3) Delete(name string) error
- func (s *S3) Read(name string, rang *Range, dest io.Writer) error
- func (s *S3) ReadDir(dir string, opts ListOption) ([]fs.FileInfo, error)
- func (s *S3) Rename(old, new string) error
- func (s *S3) Stat(name string) (fs.FileInfo, error)
- func (s *S3) String() string
- func (s *S3) Touched(name string) bool
- func (s *S3) Write(name string, source io.Reader) error
- type S3Config
- type SFTP
- func (s *SFTP) Close() error
- func (s *SFTP) Delete(name string) error
- func (s *SFTP) Read(name string, rang *Range, dest io.Writer) error
- func (s *SFTP) ReadDir(dir string, opts ListOption) ([]fs.FileInfo, error)
- func (s *SFTP) Rename(old, new string) error
- func (s *SFTP) Stat(name string) (os.FileInfo, error)
- func (s *SFTP) String() string
- func (s *SFTP) Touched(name string) bool
- func (s *SFTP) Write(name string, source io.Reader) error
- type SFTPConfig
- type Source
Constants ¶
View Source
const SizeAll = -1
Variables ¶
View Source
var SampleConfig = []string{
"sftp://username:password@hostname?key=key",
"s3://accessKey:secret@s3.eu-central-1.amazonaws.com/bucket",
"file://path",
}
Functions ¶
func ToUrl ¶
func ToUrl(config SFTPConfig) string
func UnlockFile ¶
Types ¶
type Config ¶
type Config struct { SFTP *SFTPConfig `json:"sftp,omitempty" yaml:"sftp,omitempty"` S3 *S3Config `json:"s3,omitempty" yaml:"s3,omitempty"` Local *LocalConfig `json:"local,omitempty" yaml:"local,omitempty"` }
type Exchanger ¶
type Exchanger interface { //Touched returns true when some data has been written to the exchanger since the last time Touched was called Touched(name string) bool // Read reads data from a file into a writer Read(name string, rang *Range, dest io.Writer) error // Write writes data to a file name. An existing file is overwritten Write(name string, source io.Reader) error //ReadDir returns the entries of a folder content ReadDir(name string, opts ListOption) ([]fs.FileInfo, error) // Stat provides statistics about a file Stat(name string) (os.FileInfo, error) // Rename a file. Overwrite an existing file if present Rename(old, new string) error // Delete deletes a file Delete(name string) error // Close releases resources Close() error // String returns a human-readable representation of the storer (e.g. sftp://user@host.cc/path) String() string }
Exchanger is a low level interface to storage services such as S3 or SFTP
func NewExchanger ¶
NewExchanger creates a new exchanger giving a provided configuration
type ListOption ¶
type ListOption uint32
const ( // IncludeHiddenFiles includes hidden files in a list operation IncludeHiddenFiles ListOption = 1 )
type LocalConfig ¶
type LocalConfig struct {
Base string `json:"base" yaml:"base"`
}
type S3Config ¶
type S3Config struct { Region string `json:"region" yaml:"region"` Endpoint string `json:"endpoint" yaml:"endpoint"` Bucket string `json:"bucket" yaml:"bucket"` AccessKey string `json:"accessKey" yaml:"accessKey"` Secret string `json:"secret" yaml:"secret"` DisableSSL bool `json:"disableSSL" yaml:"disableSSL"` }
func ParseS3Url ¶
type SFTPConfig ¶
type SFTPConfig struct { Addr string `json:"addr" yaml:"addr"` Username string `json:"username" yaml:"username"` Password string `json:"password" yaml:"password"` KeyPath string `json:"keyPath" yaml:"keyPath"` Base string `json:"base" yaml:"base"` }
func ParseSFTPUrl ¶
func ParseSFTPUrl(s string) (SFTPConfig, error)
Click to show internal directories.
Click to hide internal directories.