s3

package
Version: v1.6.5 Latest Latest
Warning

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

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

Documentation

Overview

Package s3 implements S3 utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBucket

func CreateBucket(
	lg *zap.Logger,
	s3API s3iface.S3API,
	bucket string,
	region string,
	lifecyclePrefix string,
	lifecycleExpirationDays int64) (err error)

CreateBucket creates a S3 bucket.

func DeleteBucket

func DeleteBucket(lg *zap.Logger, s3API s3iface.S3API, bucket string) error

DeleteBucket deletes S3 bucket.

func Download

func Download(lg *zap.Logger, s3API s3iface.S3API, bucket string, s3Key string, localPath string, opts ...OpOption) (err error)

Download downloads the file from the S3 bucket.

func DownloadDir

func DownloadDir(lg *zap.Logger, s3API s3iface.S3API, bucket string, s3Dir string, opts ...OpOption) (targetDir string, err error)

DownloadDir downloads all files from the directory in the S3 bucket.

func DownloadToTempFile

func DownloadToTempFile(lg *zap.Logger, s3API s3iface.S3API, bucket string, s3Key string, opts ...OpOption) (localPath string, err error)

DownloadToTempFile downloads the file from the S3 bucket to a temporary file.

func EmptyBucket

func EmptyBucket(lg *zap.Logger, s3API s3iface.S3API, bucket string) error

EmptyBucket empties S3 bucket, by deleting all files in the bucket.

func Exist

func Exist(lg *zap.Logger, s3API s3iface.S3API, bucket string, s3Key string, opts ...OpOption) (exist bool, err error)

Exist returns true if the object exists.

func ListInDescendingLastModified

func ListInDescendingLastModified(lg *zap.Logger, s3API s3iface.S3API, bucket string, s3KeyPfx string, opts ...OpOption) (s3Objects []*s3.Object, err error)

ListInDescendingLastModified returns s3 objects which are sorted in "descending" order of last modified timestamps. That is, the first element in the response is of the "most" recent and highest last modified timestamp value.

func PollUntilExist

func PollUntilExist(
	ctx context.Context,
	stopc chan struct{},
	lg *zap.Logger,
	s3API s3iface.S3API,
	bucket string,
	s3Key string,
	initialWait time.Duration,
	pollInterval time.Duration,
) <-chan HeadObjectStatus

PollUntilExist waits until the object exists.

func Upload

func Upload(
	lg *zap.Logger,
	s3API s3iface.S3API,
	bucket string,
	s3Key string,
	fpath string) error

Upload uploads a file to S3 bucket.

func UploadBody

func UploadBody(
	lg *zap.Logger,
	s3API s3iface.S3API,
	bucket string,
	s3Key string,
	body io.ReadSeeker) (err error)

UploadBody uploads the body reader to S3.

Types

type HeadObjectStatus

type HeadObjectStatus struct {
	HeadObject *s3.HeadObjectOutput
	Error      error
}

HeadObjectStatus represents the S3 object head status.

type Op

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

Op represents a SSH operation.

type OpOption

type OpOption func(*Op)

OpOption configures archiver operations.

func WithOverwrite

func WithOverwrite(b bool) OpOption

WithOverwrite configures overwrites.

func WithTimeout

func WithTimeout(timeout time.Duration) OpOption

WithTimeout configures request timeouts.

func WithVerbose

func WithVerbose(b bool) OpOption

WithVerbose configures verbose level in SSH operations.

Source Files

Jump to

Keyboard shortcuts

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