s3util

package
v0.0.0-...-3f59448 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package s3util contains utilities for working with the file system.

Package s3util contains methods for interracting with S3.

Index

Constants

View Source
const EndpointPattern = "^(.+\\.)?s3[.-]([a-z0-9-]+)\\."

EndpointPattern is a valid regular expression for s3 url pattern

Variables

This section is empty.

Functions

This section is empty.

Types

type AmazonS3URL

type AmazonS3URL struct {
	IsValidS3URI bool
	IsPathStyle  bool
	Bucket       string
	Key          string
	Region       string
}

AmazonS3URL holds interesting pieces after parsing a s3 URL

func ParseAmazonS3URL

func ParseAmazonS3URL(log log.T, s3URL *url.URL) (output AmazonS3URL)

ParseAmazonS3URL parses a URL and returns AmazonS3URL object

func (AmazonS3URL) IsBucketAndKeyPresent

func (output AmazonS3URL) IsBucketAndKeyPresent() bool

IsBucketAndKeyPresent checks the AmazonS3URL if it contains both bucket and key

func (AmazonS3URL) String

func (output AmazonS3URL) String() string

String returns the string representation of the AmazonS3URL

type Manager

type Manager struct {
	S3 *s3.S3
}

Manager is an object that can interact with s3.

func NewManager

func NewManager(s3 *s3.S3) *Manager

NewManager creates a new Manager object.

func (*Manager) GetS3BucketRegionFromErrorMsg

func (m *Manager) GetS3BucketRegionFromErrorMsg(log log.T, errMsg string) string

GetS3BucketRegionFromErrorMsg gets the expected region from the error message

func (Manager) GetS3ClientRegion

func (m Manager) GetS3ClientRegion() string

GetS3ClientRegion returns the S3 client's region

func (*Manager) IsS3ErrorRelatedToAccessDenied

func (m *Manager) IsS3ErrorRelatedToAccessDenied(errMsg string) bool

IsS3ErrorRelatedToAccessDenied determines if the given error message regarding AccessDenied

func (*Manager) IsS3ErrorRelatedToWrongBucketRegion

func (m *Manager) IsS3ErrorRelatedToWrongBucketRegion(errMsg string) bool

IsS3ErrorRelatedToWrongBucketRegion determines if the given error message is related to S3 bucket being in a different region than the one mentioned in S3client.

func (*Manager) S3DeleteKey

func (m *Manager) S3DeleteKey(bucketName string, objectKey string) (err error)

S3DeleteKey deletes an s3 object.

func (*Manager) S3Download

func (m *Manager) S3Download(bucketName string, objectKey string) (data []byte, err error)

S3Download downloads an s3 object in memory.

func (*Manager) S3Upload

func (m *Manager) S3Upload(bucketName string, objectKey string, filePath string) (err error)

S3Upload uploads a file to s3.

func (*Manager) S3UploadFromReader

func (m *Manager) S3UploadFromReader(bucketName string, objectKey string, content io.ReadSeeker) (err error)

S3UploadFromReader uploads data to s3 from an io.ReadSeeker.

func (*Manager) SetS3ClientRegion

func (m *Manager) SetS3ClientRegion(region string)

SetS3ClientRegion returns the S3 client's region

func (*Manager) UploadS3TestFile

func (m *Manager) UploadS3TestFile(log log.T, bucketName, key string) error

UploadS3TestFile uploads a test S3 file (with current datetime) to given s3 bucket and key

type MockS3Uploader

type MockS3Uploader struct {
	mock.Mock
}

MockS3Uploader mocks an s3 uploader.

func (*MockS3Uploader) GetS3BucketRegionFromErrorMsg

func (uploader *MockS3Uploader) GetS3BucketRegionFromErrorMsg(log log.T, errMsg string) string

GetS3BucketRegionFromErrorMsg mocks the method with the same name.

func (*MockS3Uploader) GetS3ClientRegion

func (uploader *MockS3Uploader) GetS3ClientRegion() string

GetS3ClientRegion mocks the method with the same name.

func (*MockS3Uploader) IsS3ErrorRelatedToAccessDenied

func (uploader *MockS3Uploader) IsS3ErrorRelatedToAccessDenied(errMsg string) bool

IsS3ErrorRelatedToAccessDenied mocks the method with the same name.

func (*MockS3Uploader) IsS3ErrorRelatedToWrongBucketRegion

func (uploader *MockS3Uploader) IsS3ErrorRelatedToWrongBucketRegion(errMsg string) bool

IsS3ErrorRelatedToWrongBucketRegion mocks the method with the same name.

func (*MockS3Uploader) S3Upload

func (uploader *MockS3Uploader) S3Upload(bucketName string, bucketKey string, contentPath string) error

S3Upload mocks the method with the same name.

func (*MockS3Uploader) SetS3ClientRegion

func (uploader *MockS3Uploader) SetS3ClientRegion(region string)

SetS3ClientRegion mocks the method with the same name.

func (*MockS3Uploader) UploadS3TestFile

func (uploader *MockS3Uploader) UploadS3TestFile(log log.T, bucketName, key string) error

UploadS3TestFile mocks the method with the same name.

Jump to

Keyboard shortcuts

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