fs

package
Version: v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureStorage

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

AzureStorage stores files on Azure Blob Storage

func (*AzureStorage) Delete

func (f *AzureStorage) Delete(ctx context.Context, name string, tag interface{}) (err error)

func (*AzureStorage) Get

func (f *AzureStorage) Get(ctx context.Context, name string, out io.Writer, metadataCb crypto.MetadataCb) (found bool, tag interface{}, err error)

func (*AzureStorage) GetInfoFile

func (f *AzureStorage) GetInfoFile() (info *infofile.InfoFile, err error)

func (*AzureStorage) GetKeyId added in v0.5.0

func (f *AzureStorage) GetKeyId() string

GetKeyId returns the ID of the key used

func (*AzureStorage) GetMasterKey added in v0.5.0

func (f *AzureStorage) GetMasterKey() []byte

GetMasterKey returns the master key

func (*AzureStorage) GetWithRange added in v0.5.0

func (f *AzureStorage) GetWithRange(ctx context.Context, name string, out io.Writer, rng *RequestRange, metadataCb crypto.MetadataCb) (found bool, tag interface{}, err error)

func (*AzureStorage) InitWithConnectionString added in v0.5.0

func (f *AzureStorage) InitWithConnectionString(connection string, cache *MetadataCache) error

func (*AzureStorage) InitWithOptionsMap added in v0.5.0

func (f *AzureStorage) InitWithOptionsMap(opts map[string]string, cache *MetadataCache) error

func (*AzureStorage) Set

func (f *AzureStorage) Set(ctx context.Context, name string, in io.Reader, tag interface{}, metadata *crypto.Metadata) (tagOut interface{}, err error)

func (*AzureStorage) SetInfoFile

func (f *AzureStorage) SetInfoFile(info *infofile.InfoFile) (err error)

func (*AzureStorage) SetMasterKey

func (f *AzureStorage) SetMasterKey(keyId string, key []byte)

SetMasterKey sets the master key (used to encrypt/decrypt files) in the object

type Fs

type Fs interface {
	// InitWithOptionsMap inits the object by passing an options map
	InitWithOptionsMap(opts map[string]string, cache *MetadataCache) error

	// InitWithConnectionString inits the object by passing a connection string and the cache object
	InitWithConnectionString(connection string, cache *MetadataCache) error

	// SetMasterKey sets the master key (used to encrypt/decrypt files) in the object
	SetMasterKey(keyId string, key []byte)

	// GetMasterKey returns the master key
	GetMasterKey() []byte

	// GetKeyId returns the ID of the key used
	GetKeyId() string

	// GetInfoFile returns the contents of the info file
	GetInfoFile() (info *infofile.InfoFile, err error)

	// SetInfoFile stores the info file
	SetInfoFile(info *infofile.InfoFile) (err error)

	// Get returns a stream to a file in the filesystem
	// It also returns a tag (which might be empty) that should be passed to the Set method if you want to subsequentially update the contents of the file
	Get(ctx context.Context, name string, out io.Writer, metadataCb crypto.MetadataCb) (found bool, tag interface{}, err error)

	// GetWithRange is like Get, but accepts a custom range
	GetWithRange(ctx context.Context, name string, out io.Writer, rng *RequestRange, metadataCb crypto.MetadataCb) (found bool, tag interface{}, err error)

	// Set writes a stream to the file in the filesystem
	// If you pass a tag, the implementation might use that to ensure that the file on the filesystem hasn't been changed since it was read (optional)
	Set(ctx context.Context, name string, in io.Reader, tag interface{}, metadata *crypto.Metadata) (tagOut interface{}, err error)

	// Delete a file from the filesystem
	// If you pass a tag, the implementation might use that to ensure that the file on the filesystem hasn't been changed since it was read (optional)
	Delete(ctx context.Context, name string, tag interface{}) (err error)
}

Fs is the interface for the filesystem

func GetWithConnectionString added in v0.5.0

func GetWithConnectionString(connection string) (store Fs, err error)

GetWithConnectionString returns a store for the given connection string

func GetWithOptionsMap added in v0.5.0

func GetWithOptionsMap(opts map[string]string) (store Fs, err error)

GetWithOptionsMap returns a store given the options map The dictionary must have a key "type" for the type of fs to use

type Local

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

Local is the local file system This implementation does not rely on tags, as it's assumed that concurrency isn't an issue on a single machine

func (*Local) Delete

func (f *Local) Delete(ctx context.Context, name string, tag interface{}) (err error)

func (*Local) Get

func (f *Local) Get(ctx context.Context, name string, out io.Writer, metadataCb crypto.MetadataCb) (found bool, tag interface{}, err error)

func (*Local) GetInfoFile

func (f *Local) GetInfoFile() (info *infofile.InfoFile, err error)

func (*Local) GetKeyId added in v0.5.0

func (f *Local) GetKeyId() string

GetKeyId returns the ID of the key used

func (*Local) GetMasterKey added in v0.5.0

func (f *Local) GetMasterKey() []byte

GetMasterKey returns the master key

func (*Local) GetWithRange added in v0.5.0

func (f *Local) GetWithRange(ctx context.Context, name string, out io.Writer, rng *RequestRange, metadataCb crypto.MetadataCb) (found bool, tag interface{}, err error)

func (*Local) InitWithConnectionString added in v0.5.0

func (f *Local) InitWithConnectionString(connection string, cache *MetadataCache) error

func (*Local) InitWithOptionsMap added in v0.5.0

func (f *Local) InitWithOptionsMap(opts map[string]string, cache *MetadataCache) error

func (*Local) Set

func (f *Local) Set(ctx context.Context, name string, in io.Reader, tag interface{}, metadata *crypto.Metadata) (tagOut interface{}, err error)

func (*Local) SetInfoFile

func (f *Local) SetInfoFile(info *infofile.InfoFile) (err error)

func (*Local) SetMasterKey

func (f *Local) SetMasterKey(keyId string, key []byte)

SetMasterKey sets the master key (used to encrypt/decrypt files) in the object

type MetadataCache added in v0.5.0

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

MetadataCache is a LRU cache for metadata objects

func (*MetadataCache) Add added in v0.5.0

func (c *MetadataCache) Add(name string, headerVersion uint16, headerLength int32, wrappedKey []byte, metadataLength int32, metadata *crypto.Metadata)

Add an item to the cache

func (*MetadataCache) Contains added in v0.5.0

func (c *MetadataCache) Contains(name string) bool

Contains returns true if the item is cached

func (*MetadataCache) Get added in v0.5.0

func (c *MetadataCache) Get(name string) (headerVersion uint16, headerLength int32, wrappedKey []byte, metadataLength int32, metadata *crypto.Metadata)

Get returns an element from the cache

func (*MetadataCache) Init added in v0.5.0

func (c *MetadataCache) Init() (err error)

Init the object

func (*MetadataCache) Keys added in v0.5.0

func (c *MetadataCache) Keys() []string

Keys returns the list of keys in the cache

func (*MetadataCache) Purge added in v0.5.0

func (c *MetadataCache) Purge()

Purge the cache, removing all elements

func (*MetadataCache) Remove added in v0.5.0

func (c *MetadataCache) Remove(name string)

Remove an element from the cache

type RequestRange added in v0.5.0

type RequestRange struct {
	// Start of the range that is requested from the plaintext, in bytes
	Start int64
	// Amount of data requested in plaintext, from the Start byte
	Length int64
	// Size of the header added by prvt at the beginning of the file (encoded crypto.Header, including size bytes)
	HeaderOffset int64
	// Size of the encoded metadata object added at the beginning of the plaintext (encoded crypto.Metadata, including 2 size bytes)
	MetadataOffset int64
	// File size, which acts as hard cap if set
	FileSize int64
}

RequestRange is used to request a range of data only This function uses both bytes and packages, as generated by minio/sio; each package is 64KB + 32 bytes

func NewRequestRange added in v0.5.0

func NewRequestRange(rng *utils.HttpRange) *RequestRange

NewRequestRange returns a new RequestRange object from a HttpRange one

func (*RequestRange) EndBytes added in v0.5.0

func (c *RequestRange) EndBytes() int64

EndBytes returns the end value in bytes Thats the end range for the request to the fs

func (*RequestRange) EndPackage added in v0.5.0

func (c *RequestRange) EndPackage() uint32

EndPackage returns the end package number

func (*RequestRange) LengthBytes added in v0.5.0

func (c *RequestRange) LengthBytes() int64

LengthBytes returns the number of bytes that need to be requested

func (*RequestRange) LengthPackages added in v0.5.0

func (c *RequestRange) LengthPackages() uint32

LengthPackages returns the number of packages that need to be requested

func (*RequestRange) RequestHeaderValue added in v0.5.0

func (c *RequestRange) RequestHeaderValue() string

RequestHeaderValue returns the value for the Range HTTP request reader, in bytes

func (*RequestRange) ResponseHeaderValue added in v0.5.0

func (c *RequestRange) ResponseHeaderValue() string

ResponseHeaderValue returns the value for the Content-Range HTTP response reader, in bytes

func (*RequestRange) SetFileSize added in v0.5.0

func (c *RequestRange) SetFileSize(size int64)

SetFileSize sets the FileSize value and ensures that Start and Length don't overflow

func (*RequestRange) SkipBeginning added in v0.5.0

func (c *RequestRange) SkipBeginning() int

SkipBeginning returns the number of bytes that need to be skipped from the beginning of the (decrypted) stream to match the requested range

func (*RequestRange) StartBytes added in v0.5.0

func (c *RequestRange) StartBytes() int64

StartBytes returns the start value in bytes That's the start range for the request to the fs

func (*RequestRange) StartPackage added in v0.5.0

func (c *RequestRange) StartPackage() uint32

StartPackage returns the start package number

func (*RequestRange) String added in v0.5.0

func (c *RequestRange) String() string

type S3 added in v0.1.1

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

S3 stores files on a S3-compatible service This implementation does not rely on tags because S3 does not support conditional put requests

func (*S3) Delete added in v0.1.1

func (f *S3) Delete(ctx context.Context, name string, tag interface{}) (err error)

func (*S3) Get added in v0.1.1

func (f *S3) Get(ctx context.Context, name string, out io.Writer, metadataCb crypto.MetadataCb) (found bool, tag interface{}, err error)

func (*S3) GetInfoFile added in v0.1.1

func (f *S3) GetInfoFile() (info *infofile.InfoFile, err error)

func (*S3) GetKeyId added in v0.5.0

func (f *S3) GetKeyId() string

GetKeyId returns the ID of the key used

func (*S3) GetMasterKey added in v0.5.0

func (f *S3) GetMasterKey() []byte

GetMasterKey returns the master key

func (*S3) GetWithRange added in v0.5.0

func (f *S3) GetWithRange(ctx context.Context, name string, out io.Writer, rng *RequestRange, metadataCb crypto.MetadataCb) (found bool, tag interface{}, err error)

func (*S3) InitWithConnectionString added in v0.5.0

func (f *S3) InitWithConnectionString(connection string, cache *MetadataCache) error

func (*S3) InitWithOptionsMap added in v0.5.0

func (f *S3) InitWithOptionsMap(opts map[string]string, cache *MetadataCache) error

func (*S3) Set added in v0.1.1

func (f *S3) Set(ctx context.Context, name string, in io.Reader, tag interface{}, metadata *crypto.Metadata) (tagOut interface{}, err error)

func (*S3) SetInfoFile added in v0.1.1

func (f *S3) SetInfoFile(info *infofile.InfoFile) (err error)

func (*S3) SetMasterKey added in v0.1.1

func (f *S3) SetMasterKey(keyId string, key []byte)

SetMasterKey sets the master key (used to encrypt/decrypt files) in the object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL