storage

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package storage provides basic storage interfaces for storage providers to write / read objects to and from

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidS3Bucket is returned when an invalid s3 bucket is provided
	ErrInvalidS3Bucket = errors.New("invalid s3 bucket provided")
	// ErrInvalidFolderPath is returned when an invalid folder path is provided
	ErrInvalidFolderPath = errors.New("invalid folder path provided")
)

Functions

This section is empty.

Types

type Disk

type Disk struct {
	Scheme string
	// contains filtered or unexported fields
}

func NewDiskStorage

func NewDiskStorage(folder string) (*Disk, error)

func (*Disk) Close

func (d *Disk) Close() error

func (*Disk) Download

Download is used to download a file from the storage backend TODO: Implement this method

func (*Disk) GetPresignedURL

func (d *Disk) GetPresignedURL(ctx context.Context, key string) (string, error)

GetPresignedURL is used to get a presigned URL for a file in the storage backend TODO: Implement this method

func (*Disk) GetScheme

func (d *Disk) GetScheme() *string

GetScheme returns the scheme of the storage backend

func (*Disk) ManagerUpload

func (d *Disk) ManagerUpload(ctx context.Context, files [][]byte) error

ManagerUpload uploads multiple files to disk TODO: Implement this method

func (*Disk) Upload

type S3Options

type S3Options struct {
	// Bucket to store objects in
	Bucket string
	// DebugMode will log all requests and responses
	DebugMode bool
	// UsePathStyle allows you to enable the client to use path-style addressing, i.e., https://s3.amazonaws.com/BUCKET/KEY .
	// by default, the S3 client will use virtual hosted bucket addressing when possible( https://BUCKET.s3.amazonaws.com/KEY ).
	UsePathStyle bool
	// ACL should only be used if the bucket supports ACL
	ACL types.ObjectCannedACL
	// KeyNamespace is used to prefix all keys with a namespace
	KeyNamespace string
}

S3Options is used to configure the S3Store

type S3Store

type S3Store struct {
	Client             *s3.Client
	Opts               S3Options
	PresignClient      *s3.PresignClient
	Downloader         *manager.Downloader
	Uploader           *manager.Uploader
	ObjExistsWaiter    *s3.ObjectExistsWaiter
	ObjNotExistsWaiter *s3.ObjectNotExistsWaiter
	ACL                types.ObjectCannedACL
	CacheControl       string
	Scheme             string
}

S3Store is a store that uses S3 as the backend

func NewS3FromConfig

func NewS3FromConfig(cfg aws.Config, opts S3Options) (*S3Store, error)

NewS3FromConfig creates a new S3Store from the provided configuration

func (*S3Store) Close

func (s *S3Store) Close() error

Close the S3Store satisfying the Storage interface

func (*S3Store) Download

Download an object from S3 and return the metadata and a reader

func (*S3Store) Exists

func (s *S3Store) Exists(ctx context.Context, key string) (bool, error)

Exists checks if an object exists in S3

func (*S3Store) GetPresignedURL

func (s *S3Store) GetPresignedURL(ctx context.Context, key string) (string, error)

PresignedURL returns a URL that provides access to a file for 15 minutes

func (*S3Store) GetPresignedURLWithCustomDuration

func (s *S3Store) GetPresignedURLWithCustomDuration(ctx context.Context, key string, expires time.Duration) (string, error)

PresignedURL returns a URL that provides access to a file with a custom duration

func (*S3Store) GetScheme

func (s *S3Store) GetScheme() *string

GetScheme returns the scheme of the storage backend

func (*S3Store) ManagerUpload

func (s *S3Store) ManagerUpload(ctx context.Context, files [][]byte) error

ManagerUpload uploads multiple files to S3

func (*S3Store) Upload

Upload an object to S3 and return the metadata

Jump to

Keyboard shortcuts

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