Documentation ¶
Overview ¶
Package s3util contains utilities for working with the file system.
Package s3util contains methods for interracting with S3.
Index ¶
- Constants
- type AmazonS3URL
- type Manager
- func (m *Manager) GetS3BucketRegionFromErrorMsg(log log.T, errMsg string) string
- func (m Manager) GetS3ClientRegion() string
- func (m *Manager) IsS3ErrorRelatedToAccessDenied(errMsg string) bool
- func (m *Manager) IsS3ErrorRelatedToWrongBucketRegion(errMsg string) bool
- func (m *Manager) S3DeleteKey(bucketName string, objectKey string) (err error)
- func (m *Manager) S3Download(bucketName string, objectKey string) (data []byte, err error)
- func (m *Manager) S3Upload(bucketName string, objectKey string, filePath string) (err error)
- func (m *Manager) S3UploadFromReader(bucketName string, objectKey string, content io.ReadSeeker) (err error)
- func (m *Manager) SetS3ClientRegion(region string)
- func (m *Manager) UploadS3TestFile(log log.T, bucketName, key string) error
- type MockS3Uploader
- func (uploader *MockS3Uploader) GetS3BucketRegionFromErrorMsg(log log.T, errMsg string) string
- func (uploader *MockS3Uploader) GetS3ClientRegion() string
- func (uploader *MockS3Uploader) IsS3ErrorRelatedToAccessDenied(errMsg string) bool
- func (uploader *MockS3Uploader) IsS3ErrorRelatedToWrongBucketRegion(errMsg string) bool
- func (uploader *MockS3Uploader) S3Upload(bucketName string, bucketKey string, contentPath string) error
- func (uploader *MockS3Uploader) SetS3ClientRegion(region string)
- func (uploader *MockS3Uploader) UploadS3TestFile(log log.T, bucketName, key string) error
Constants ¶
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 ¶
Manager is an object that can interact with s3.
func (*Manager) GetS3BucketRegionFromErrorMsg ¶
GetS3BucketRegionFromErrorMsg gets the expected region from the error message
func (Manager) GetS3ClientRegion ¶
GetS3ClientRegion returns the S3 client's region
func (*Manager) IsS3ErrorRelatedToAccessDenied ¶
IsS3ErrorRelatedToAccessDenied determines if the given error message regarding AccessDenied
func (*Manager) IsS3ErrorRelatedToWrongBucketRegion ¶
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 ¶
S3DeleteKey deletes an s3 object.
func (*Manager) S3Download ¶
S3Download downloads an s3 object in memory.
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 ¶
SetS3ClientRegion returns the S3 client's region
type MockS3Uploader ¶
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.