s3

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// GCSEndpointURL is the endpoint url for Google Clound Strage service
	GCSEndpointURL = "storage.googleapis.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSsse added in v1.3.2

type AWSsse struct {
	SseAlgorithm string `bson:"sseAlgorithm" json:"sseAlgorithm" yaml:"sseAlgorithm"`
	KmsKeyID     string `bson:"kmsKeyID" json:"kmsKeyID" yaml:"kmsKeyID"`
}

type Conf

type Conf struct {
	Provider             S3Provider  `bson:"provider,omitempty" json:"provider,omitempty" yaml:"provider,omitempty"`
	Region               string      `bson:"region" json:"region" yaml:"region"`
	EndpointURL          string      `bson:"endpointUrl,omitempty" json:"endpointUrl" yaml:"endpointUrl,omitempty"`
	Bucket               string      `bson:"bucket" json:"bucket" yaml:"bucket"`
	Prefix               string      `bson:"prefix,omitempty" json:"prefix,omitempty" yaml:"prefix,omitempty"`
	Credentials          Credentials `bson:"credentials" json:"-" yaml:"credentials"`
	ServerSideEncryption *AWSsse     `bson:"serverSideEncryption,omitempty" json:"serverSideEncryption,omitempty" yaml:"serverSideEncryption,omitempty"`
	UploadPartSize       int         `bson:"uploadPartSize,omitempty" json:"uploadPartSize,omitempty" yaml:"uploadPartSize,omitempty"`
}

func (*Conf) Cast

func (c *Conf) Cast() error

type Credentials

type Credentials struct {
	AccessKeyID     string `bson:"access-key-id" json:"access-key-id,omitempty" yaml:"access-key-id,omitempty"`
	SecretAccessKey string `bson:"secret-access-key" json:"secret-access-key,omitempty" yaml:"secret-access-key,omitempty"`
	Vault           struct {
		Server string `bson:"server" json:"server,omitempty" yaml:"server"`
		Secret string `bson:"secret" json:"secret,omitempty" yaml:"secret"`
		Token  string `bson:"token" json:"token,omitempty" yaml:"token"`
	} `bson:"vault" json:"vault" yaml:"vault,omitempty"`
}

type S3

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

func New

func New(opts Conf, l *log.Event) (*S3, error)

func (*S3) Copy added in v1.6.0

func (s *S3) Copy(src, dst string) error

func (*S3) Delete

func (s *S3) Delete(name string) error

Delete deletes given file. It returns storage.ErrNotExist if a file isn't exists

func (*S3) FileStat added in v1.4.0

func (s *S3) FileStat(name string) (inf storage.FileInfo, err error)

func (*S3) List added in v1.3.0

func (s *S3) List(prefix, suffix string) ([]storage.FileInfo, error)

func (*S3) Save

func (s *S3) Save(name string, data io.Reader, sizeb int) error

func (*S3) SourceReader

func (s *S3) SourceReader(name string) (io.ReadCloser, error)

SourceReader reads object with the given name from S3 and pipes its data to the returned io.ReadCloser.

It uses partReader to download the object by chunks (`downloadChuckSize`). In case of error, it would retry get the next bytes up to `downloadRetries` times. If it fails to do so or connection error happened, it recreates the session and tries again up to `downloadRetries` times.

type S3Provider

type S3Provider string
const (
	S3ProviderUndef S3Provider = ""
	S3ProviderAWS   S3Provider = "aws"
	S3ProviderGCS   S3Provider = "gcs"
)

Jump to

Keyboard shortcuts

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