storage

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseCheck

func CloseCheck(c io.Closer)

Types

type GDrive

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

GDrive is a storage backed by GDrive

func NewGDriveStorage

func NewGDriveStorage(ctx context.Context, clientJSONFilepath string, localConfigPath string, basedir string, chunkSize int, logger *log.Logger) (*GDrive, error)

NewGDriveStorage is the factory for GDrive

func (*GDrive) Delete

func (s *GDrive) Delete(ctx context.Context, token string, filename string) (err error)

Delete removes a file from storage

func (*GDrive) Get

func (s *GDrive) Get(ctx context.Context, token string, filename string, rng *Range) (reader io.ReadCloser, contentLength uint64, err error)

Get retrieves a file from storage

func (*GDrive) Head

func (s *GDrive) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)

Head retrieves content length of a file from storage

func (*GDrive) IsNotExist

func (s *GDrive) IsNotExist(err error) bool

IsNotExist indicates if a file doesn't exist on storage

func (*GDrive) IsRangeSupported

func (s *GDrive) IsRangeSupported() bool

func (*GDrive) Purge

func (s *GDrive) Purge(ctx context.Context, days time.Duration) (err error)

Purge cleans up the storage

func (*GDrive) Put

func (s *GDrive) Put(ctx context.Context, token string, filename string, reader io.Reader, contentType string, contentLength uint64) error

Put saves a file on storage

func (*GDrive) Type

func (s *GDrive) Type() string

Type returns the storage type

type LocalStorage

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

LocalStorage is a local storage

func NewLocalStorage

func NewLocalStorage(basedir string, logger *log.Logger) (*LocalStorage, error)

NewLocalStorage is the factory for LocalStorage

func (*LocalStorage) Delete

func (s *LocalStorage) Delete(_ context.Context, token string, filename string) (err error)

Delete removes a file from storage

func (*LocalStorage) Get

func (s *LocalStorage) Get(_ context.Context, token string, filename string, rng *Range) (reader io.ReadCloser, contentLength uint64, err error)

Get retrieves a file from storage

func (*LocalStorage) Head

func (s *LocalStorage) Head(_ context.Context, token string, filename string) (contentLength uint64, err error)

Head retrieves content length of a file from storage

func (*LocalStorage) IsNotExist

func (s *LocalStorage) IsNotExist(err error) bool

IsNotExist indicates if a file doesn't exist on storage

func (*LocalStorage) IsRangeSupported

func (s *LocalStorage) IsRangeSupported() bool

func (*LocalStorage) Purge

func (s *LocalStorage) Purge(_ context.Context, days time.Duration) (err error)

Purge cleans up the storage

func (*LocalStorage) Put

func (s *LocalStorage) Put(_ context.Context, token string, filename string, reader io.Reader, contentType string, contentLength uint64) error

Put saves a file on storage

func (*LocalStorage) Type

func (s *LocalStorage) Type() string

Type returns the storage type

type Range

type Range struct {
	Start uint64
	Limit uint64
	// contains filtered or unexported fields
}

func ParseRange

func ParseRange(rng string) *Range

Parses HTTP Range header and returns struct on success only bytes=start-finish supported

func (*Range) AcceptLength

func (r *Range) AcceptLength(contentLength uint64) (newContentLength uint64)

AcceptLength Tries to accept given range returns newContentLength if range was satisfied, otherwise returns given contentLength

func (*Range) ContentRange

func (r *Range) ContentRange() string

Returns accepted Content-Range header. If range wasn't accepted empty string is returned

func (*Range) Range

func (r *Range) Range() string

Range Reconstructs Range header and returns it

func (*Range) SetContentRange

func (r *Range) SetContentRange(cr string)

type S3Storage

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

S3Storage is a storage backed by AWS S3

func NewS3Storage

func NewS3Storage(ctx context.Context, accessKey, secretKey, bucketName string, purgeDays int, region, endpoint string, disableMultipart bool, forcePathStyle bool, logger *log.Logger) (*S3Storage, error)

NewS3Storage is the factory for S3Storage

func (*S3Storage) Delete

func (s *S3Storage) Delete(ctx context.Context, token string, filename string) (err error)

Delete removes a file from storage

func (*S3Storage) Get

func (s *S3Storage) Get(ctx context.Context, token string, filename string, rng *Range) (reader io.ReadCloser, contentLength uint64, err error)

Get retrieves a file from storage

func (*S3Storage) Head

func (s *S3Storage) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)

Head retrieves content length of a file from storage

func (*S3Storage) IsNotExist

func (s *S3Storage) IsNotExist(err error) bool

IsNotExist indicates if a file doesn't exist on storage

func (*S3Storage) IsRangeSupported

func (s *S3Storage) IsRangeSupported() bool

func (*S3Storage) Purge

func (s *S3Storage) Purge(context.Context, time.Duration) (err error)

Purge cleans up the storage

func (*S3Storage) Put

func (s *S3Storage) Put(ctx context.Context, token string, filename string, reader io.Reader, contentType string, _ uint64) (err error)

Put saves a file on storage

func (*S3Storage) Type

func (s *S3Storage) Type() string

Type returns the storage type

type Storage

type Storage interface {
	// Get retrieves a file from storage
	Get(ctx context.Context, token string, filename string, rng *Range) (reader io.ReadCloser, contentLength uint64, err error)
	// Head retrieves content length of a file from storage
	Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)
	// Put saves a file on storage
	Put(ctx context.Context, token string, filename string, reader io.Reader, contentType string, contentLength uint64) error
	// Delete removes a file from storage
	Delete(ctx context.Context, token string, filename string) error
	// IsNotExist indicates if a file doesn't exist on storage
	IsNotExist(err error) bool
	// Purge cleans up the storage
	Purge(ctx context.Context, days time.Duration) error
	// Whether storage supports Get with Range header
	IsRangeSupported() bool
	// Type returns the storage type
	Type() string
}

Storage is the interface for storage operation

type StorjStorage

type StorjStorage struct {
	Storage
	// contains filtered or unexported fields
}

StorjStorage is a storage backed by Storj

func NewStorjStorage

func NewStorjStorage(ctx context.Context, access, bucket string, purgeDays int, logger *log.Logger) (*StorjStorage, error)

NewStorjStorage is the factory for StorjStorage

func (*StorjStorage) Delete

func (s *StorjStorage) Delete(ctx context.Context, token string, filename string) (err error)

Delete removes a file from storage

func (*StorjStorage) Get

func (s *StorjStorage) Get(ctx context.Context, token string, filename string, rng *Range) (reader io.ReadCloser, contentLength uint64, err error)

Get retrieves a file from storage

func (*StorjStorage) Head

func (s *StorjStorage) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)

Head retrieves content length of a file from storage

func (*StorjStorage) IsNotExist

func (s *StorjStorage) IsNotExist(err error) bool

IsNotExist indicates if a file doesn't exist on storage

func (*StorjStorage) IsRangeSupported

func (s *StorjStorage) IsRangeSupported() bool

func (*StorjStorage) Purge

func (s *StorjStorage) Purge(context.Context, time.Duration) (err error)

Purge cleans up the storage

func (*StorjStorage) Put

func (s *StorjStorage) Put(ctx context.Context, token string, filename string, reader io.Reader, contentType string, contentLength uint64) (err error)

Put saves a file on storage

func (*StorjStorage) Type

func (s *StorjStorage) Type() string

Type returns the storage type

Jump to

Keyboard shortcuts

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