s3

package
v0.0.0-...-f26095a Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package s3 imlements wrappers for AWS S3 service

Uses the default AWS SDK Credentials; e.g. via the environment AWS_REGION=region AWS_ACCESS_KEY_ID=key AWS_SECRET_ACCESS_KEY=secret OR in the AWS SDK credential configurtion ~/.aws/credentials:

aws_access_key_id = AKID aws_secret_access_key = SECRET aws_session_token = TOKEN

See: https://docs.aws.amazon.com/sdk-for-go/api/aws/session/#pkg-overview

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name, Owner, Repr string
	Size              int64
}

Entry S3 entry returned by List

type FileManager

type FileManager interface {
	Download(fileName, containerName, sourceName, destinationName string) (string, error)
	List(bucket, prefix string) ([]Entry, error)
	Upload(fileName, containerName, key string) (string, error)
}

FileManager generic file downloader interfacae

type LocalManager

type LocalManager struct{ SourceDirectory, DestinationDirctory string }

LocalManager - local file system file manages (for testing)

func (LocalManager) Download

func (m LocalManager) Download(sourceName, s3BucketName, s3Key, dest string) (string, error)

Download simulates download from the SourceDirectory

func (LocalManager) List

func (m LocalManager) List(
	bucket, prefix string) ([]Entry, error)

List lists content of a S3 bucket

func (LocalManager) Upload

func (m LocalManager) Upload(sourceName, s3BucketName, s3Key string) (string, error)

Upload upload file into DestinationDirctory

type Manager

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

Manager AWS S3 file downloader

func NewManager

func NewManager(region, profile string) Manager

NewManager instantiates an AWS S3 file Manager

func NewManagerWithCredentials

func NewManagerWithCredentials(accessKeyID, secretAccessKey, region string) Manager

NewManagerWithCredentials instantiates an AWS S3 file manager

func (Manager) Download

func (m Manager) Download(
	SourceName, S3BucketName, S3Key, DestinationFileName string) (string, error)

Download downloads a file form the given bucket to the destination file.

func (Manager) List

func (m Manager) List(
	bucket, prefix string) ([]Entry, error)

List lists content of a S3 bucket

func (Manager) Upload

func (m Manager) Upload(fileName, bucket, key string) (string, error)

Upload upload a file to the given bucket.

Jump to

Keyboard shortcuts

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