s3sessions

package
v4.2.9-beta.2+incompat... Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertS3Error

func ConvertS3Error(err error, args ...interface{}) error

ConvertS3Error wraps S3 error and returns trace equivalent

Types

type Config

type Config struct {
	// Bucket is S3 bucket name
	Bucket string
	// Region is S3 bucket region
	Region string
	// Path is an optional bucket path
	Path string
	// Host is an optional third party S3 compatible endpoint
	Endpoint string
	// Insecure is an optional switch to opt out of https connections
	Insecure bool
	//DisableServerSideEncryption is an optional switch to opt out of SSE in case the provider does not support it
	DisableServerSideEncryption bool
	// Session is an optional existing AWS client session
	Session *awssession.Session
	// Credentials if supplied are used in tests
	Credentials *credentials.Credentials
}

Config is handler configuration

func (*Config) CheckAndSetDefaults

func (s *Config) CheckAndSetDefaults() error

CheckAndSetDefaults checks and sets defaults

func (*Config) SetFromURL

func (s *Config) SetFromURL(in *url.URL, inRegion string) error

SetFromURL sets values on the Config from the supplied URI

type Handler

type Handler struct {
	// Config is handler configuration
	Config
	// Entry is a logging entry
	*log.Entry
	// contains filtered or unexported fields
}

Handler handles upload and downloads to S3 object storage

func NewHandler

func NewHandler(cfg Config) (*Handler, error)

NewHandler returns new S3 uploader

func (*Handler) Close

func (l *Handler) Close() error

Closer releases connection and resources associated with log if any

func (*Handler) Download

func (l *Handler) Download(ctx context.Context, sessionID session.ID, writer io.WriterAt) error

Download downloads recorded session from S3 bucket and writes the results into writer return trace.NotFound error is object is not found.

func (*Handler) Upload

func (l *Handler) Upload(ctx context.Context, sessionID session.ID, reader io.Reader) (string, error)

Upload uploads object to S3 bucket, reads the contents of the object from reader and returns the target S3 bucket path in case of successful upload.

Jump to

Keyboard shortcuts

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