objectstorage

package
v0.0.0-...-e31961d Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

README

Objectstorage

Wrapper of go cloud blob library

Documentation

Index

Constants

View Source
const (
	// local storage for testing
	StorageLocal = "local"
	// google cloud storage
	StorageGCS = "gcs"
	// amazon s3 storage
	StorageS3 = "s3"
	// digital ocean space storage
	StorageDO = "do"
	// minio storage
	StorageMinio = "minio"
)

storage type of artifact

Variables

View Source
var (
	ErrByteEmpty        = errors.New("byte content is empty")
	ErrCredentialsEmpty = errors.New("credentials is empty")
)

list of error

Functions

This section is empty.

Types

type ReadOptions

type ReadOptions struct {
	// FileMode is an options when downloading file
	// using DownloadFile function
	FileMode os.FileMode
}

ReadOptions struct we might need this later on

type Storage

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

Storage struct

func New

func New(storage StorageProvider) *Storage

New artifact

func (*Storage) Attributes

func (s *Storage) Attributes(ctx context.Context, key string) (*blob.Attributes, error)

Attributes return information/attributes of object

func (*Storage) BucketName

func (s *Storage) BucketName() string

BucketName of storage provider

func (*Storage) Close

func (s *Storage) Close() error

Close will close the object storage bucket and return error

func (*Storage) Download

func (s *Storage) Download(ctx context.Context, key string, readOptions *ReadOptions) (io.Reader, error)

Download file from bucket

func (*Storage) DownloadByte

func (s *Storage) DownloadByte(ctx context.Context, key string, readOptions *ReadOptions) ([]byte, error)

DownloadByte is a helper function for downloading content with return of byte

func (*Storage) DownloadFile

func (s *Storage) DownloadFile(ctx context.Context, key, destination string, readOptions *ReadOptions) error

DownloadFile will download and create file from object storage

func (*Storage) Name

func (s *Storage) Name() string

Name of provider this might be useful if application has admin-port of something like that to retrieve the current name of the provider

func (*Storage) SignedURL

func (s *Storage) SignedURL(ctx context.Context, key string, expiry time.Duration) (string, error)

SignedURL to create a temporary URL to download a private file

func (*Storage) Stream

func (s *Storage) Stream(ctx context.Context, key string, writeOptions *WriteOptions) (*Stream, error)

Stream create a new stream object

func (*Storage) Upload

func (s *Storage) Upload(ctx context.Context, reader io.Reader, key string, writeOptions *WriteOptions) (string, error)

Upload file from bytes

func (*Storage) UploadByte

func (s *Storage) UploadByte(ctx context.Context, content []byte, key string, writeOptions *WriteOptions) (string, error)

UploadByte is a halper function for upload receiving byte param

func (*Storage) UploadFile

func (s *Storage) UploadFile(ctx context.Context, filepath, key string, writeOptions *WriteOptions) (string, error)

UploadFile file from source and destination

type StorageProvider

type StorageProvider interface {
	Bucket() *blob.Bucket
	Name() string
	BucketName() string
	BucketURL() string
	Close() error
}

StorageProvider interface

type Stream

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

Stream struct

func (*Stream) Reader

func (s *Stream) Reader(ctx context.Context, key string, readOptions *ReadOptions) (*blob.Reader, error)

Reader return blob reader

func (*Stream) Writer

func (s *Stream) Writer(ctx context.Context, key string, writeOptions *WriteOptions) (*blob.Writer, error)

Writer return blob writer

type WriteOptions

type WriteOptions struct {
	// BufferSize for writing many small writes concurrently
	BufferSize int
	// ContentType specifies the MIME type of the blob
	ContentType string
	// ContentDisposition specifies whether the content is displayed inline or as attachment
	ContentDisposition string
	// ContentEncoding to store specific encoding for the content
	ContentEncoding string
	// ContentLanguage for language of the content
	ContentLanguage string
	// ContentMD5 for integrity check
	ContentMD5 []byte
	// Key-value associated with the blob
	Metadata map[string]string
}

WriteOptions struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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