filestorage

package
v0.0.0-...-72c2bb7 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNameTooSmall = errors.New("name length must be greater than 5")
)

Functions

func PathFromData

func PathFromData(address *am.ScanGroupAddress, name string) string

PathFromData takes in an address and raw bytes to create a hashed / sharded path name

func ShardName

func ShardName(name string) (string, error)

ShardName takes an input name and shards it 5 levels

Types

type LocalStorage

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

func NewLocalStorage

func NewLocalStorage() *LocalStorage

func (*LocalStorage) GetInfraFile

func (s *LocalStorage) GetInfraFile(ctx context.Context, pathName, objectName string) ([]byte, error)

func (*LocalStorage) Init

func (s *LocalStorage) Init() error

func (*LocalStorage) PutInfraFile

func (s *LocalStorage) PutInfraFile(ctx context.Context, pathName, objectName string, data []byte) error

func (*LocalStorage) Write

func (s *LocalStorage) Write(ctx context.Context, userContext am.UserContext, address *am.ScanGroupAddress, data []byte) (string, string, error)

Writes the data to local storage, returning the hash and link/path

func (*LocalStorage) WriteWithHash

func (s *LocalStorage) WriteWithHash(ctx context.Context, userContext am.UserContext, address *am.ScanGroupAddress, data []byte, hashName string) (string, error)

type S3Storage

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

func NewS3Storage

func NewS3Storage(env, region string) *S3Storage

func (*S3Storage) GetInfraFile

func (s *S3Storage) GetInfraFile(ctx context.Context, bucketName, objectName string) ([]byte, error)

func (*S3Storage) Init

func (s *S3Storage) Init() error

func (*S3Storage) PutInfraFile

func (s *S3Storage) PutInfraFile(ctx context.Context, bucketName, objectName string, data []byte) error

func (*S3Storage) Write

func (s *S3Storage) Write(ctx context.Context, userContext am.UserContext, address *am.ScanGroupAddress, data []byte) (string, string, error)

func (*S3Storage) WriteWithHash

func (s *S3Storage) WriteWithHash(ctx context.Context, userContext am.UserContext, address *am.ScanGroupAddress, data []byte, hashName string) (string, error)

type Storage

type Storage interface {
	Init() error
	Write(ctx context.Context, userContext am.UserContext, address *am.ScanGroupAddress, data []byte) (string, string, error)
	WriteWithHash(ctx context.Context, userContext am.UserContext, address *am.ScanGroupAddress, data []byte, hash string) (string, error)
	GetInfraFile(ctx context.Context, pathName, objectName string) ([]byte, error)
	PutInfraFile(ctx context.Context, pathName, objectName string, data []byte) error
}

func NewStorage

func NewStorage(env, region string) Storage

Jump to

Keyboard shortcuts

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