Documentation
¶
Index ¶
- type S3
- func (s *S3) Connect(parentSegment ...*xray.XRayParentSegment) (err error)
- func (s *S3) Delete(timeOutDuration *time.Duration, targetKey string, targetFolder ...string) (deleteSuccess bool, err error)
- func (s *S3) DeleteBatch(timeOutDuration *time.Duration, targetKeys []string) (deletedKeysList []string, errorList []*S3ErrorResult, err error)
- func (s *S3) Disconnect()
- func (s *S3) Download(timeOutDuration *time.Duration, targetKey string, targetFolder ...string) (data []byte, notFound bool, err error)
- func (s *S3) DownloadFile(timeOutDuration *time.Duration, writeToFilePath string, targetKey string, ...) (location string, notFound bool, err error)
- func (s *S3) ListFileKeys(timeOutDuration *time.Duration, nextToken string, maxResults int64, ...) (fileKeys []string, moreFileKeysNextToken string, err error)
- func (s *S3) UpdateParentSegment(parentSegment *xray.XRayParentSegment)
- func (s *S3) Upload(timeOutDuration *time.Duration, data []byte, targetKey string, ...) (location string, err error)
- func (s *S3) UploadFile(timeOutDuration *time.Duration, sourceFilePath string, targetKey string, ...) (location string, err error)
- type S3ErrorResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type S3 ¶
type S3 struct {
// define the AWS region that s3 is located at
AwsRegion awsregion.AWSRegion
// custom http2 client options
HttpOptions *awshttp2.HttpClientSettings
// bucket name
BucketName string
// contains filtered or unexported fields
}
S3 struct encapsulates the AWS S3 access functionality
func (*S3) Connect ¶
func (s *S3) Connect(parentSegment ...*xray.XRayParentSegment) (err error)
Connect will establish a connection to the s3 service
func (*S3) Delete ¶
func (s *S3) Delete(timeOutDuration *time.Duration, targetKey string, targetFolder ...string) (deleteSuccess bool, err error)
Delete will delete an object from S3 bucket by key
Parameters:
timeOutDuration = nil if no timeout pre-set via context; otherwise timeout duration typically in seconds via context targetKey = the actual key name without any parts with / indicating folder targetFolder = if the delete position is under one or more 'folder' sub-hierarchy, then specify the target folder names from left to right
Return Values:
deleteSuccess = true if delete was successfully completed; false if delete failed to perform, check error if any err = error encountered while attempting to download
func (*S3) DeleteBatch ¶ added in v1.5.9
func (s *S3) DeleteBatch(timeOutDuration *time.Duration, targetKeys []string) (deletedKeysList []string, errorList []*S3ErrorResult, err error)
DeleteBatch will delete up to 1,000 objects from S3 bucket by key
Parameters:
timeOutDuration = nil if no timeout pre-set via context; otherwise timeout duration typically in seconds via context targetKey = the actual key name with one or more 'folder' sub-hierarchy, such as "file1.txt", "folder2/file2.txt", "folder2/folder3/file3.txt"
Return Values:
deletedKeysList = identifies the object that was successfully deleted. errorList = describes the object that Amazon S3 attempted to delete and the error it encountered err = error encountered while attempting to download
func (*S3) Disconnect ¶
func (s *S3) Disconnect()
Disconnect will disjoin from aws session by clearing it
func (*S3) Download ¶
func (s *S3) Download(timeOutDuration *time.Duration, targetKey string, targetFolder ...string) (data []byte, notFound bool, err error)
Download will download an object from S3 bucket by key and return via byte slice
Parameters:
timeOutDuration = nil if no timeout pre-set via context; otherwise timeout duration typically in seconds via context targetKey = the actual key name without any parts with / indicating folder targetFolder = if the download position is under one or more 'folder' sub-hierarchy, then specify the target folder names from left to right
Return Values:
data = byte slice of object downloaded from s3 bucket by key notFound = key was not found in s3 bucket err = error encountered while attempting to download
func (*S3) DownloadFile ¶
func (s *S3) DownloadFile(timeOutDuration *time.Duration, writeToFilePath string, targetKey string, targetFolder ...string) (location string, notFound bool, err error)
DownloadFile will download an object from S3 bucket by key and persist into file on disk
Parameters:
timeOutDuration = nil if no timeout pre-set via context; otherwise timeout duration typically in seconds via context writeToFilePath = file path that will save the file containing s3 object content targetKey = the actual key name without any parts with / indicating folder targetFolder = if the download position is under one or more 'folder' sub-hierarchy, then specify the target folder names from left to right
Return Values:
location = local disk file path where downloaded content is stored into notFound = key was not found in s3 bucket err = error encountered while attempting to download
func (*S3) ListFileKeys ¶ added in v1.5.9
func (s *S3) ListFileKeys(timeOutDuration *time.Duration, nextToken string, maxResults int64, folder ...string) (fileKeys []string, moreFileKeysNextToken string, err error)
List will list some or all (up to 1,000) of the objects in a S3 bucket
Parameters:
timeOutDuration = optional, nil if no timeout pre-set via context; otherwise timeout duration typically in seconds via context nextToken = optional, if the prior call to List expected more values, a more...token is returned, to be used in this parameter maxResults = optional, if > 0, the maximum results limited to; By default, the action returns up to 1,000 folder = optional, if the list objects is under one or more 'folder' sub-hierarchy, then specify the folder names from left to right
Return Values:
objectKeys = string slice of object keys found moreObjectsNextToken = if more objects expected, use this token in the next method call by passing into nextToken parameter err = error encountered while attempting to download
func (*S3) UpdateParentSegment ¶ added in v1.1.4
func (s *S3) UpdateParentSegment(parentSegment *xray.XRayParentSegment)
UpdateParentSegment updates this struct's xray parent segment, if no parent segment, set nil
func (*S3) Upload ¶
func (s *S3) Upload(timeOutDuration *time.Duration, data []byte, targetKey string, targetFolder ...string) (location string, err error)
Upload will upload the specified bytes to S3 in the bucket name defined within S3 struct
Parameters:
timeOutDuration = nil if no timeout pre-set via context; otherwise timeout duration typically in seconds via context data = slice of bytes to upload to s3 targetKey = the actual key name without any parts with / indicating folder targetFolder = if the upload position is under one or more 'folder' sub-hierarchy, then specify the target folder names from left to right
Return Values:
location = value indicating the location where upload was persisted to on s3 bucket err = error encountered while attempting to upload
func (*S3) UploadFile ¶
func (s *S3) UploadFile(timeOutDuration *time.Duration, sourceFilePath string, targetKey string, targetFolder ...string) (location string, err error)
UploadFile will upload the specified file to S3 in the bucket name defined within S3 struct
Parameters:
timeOutDuration = nil if no timeout pre-set via context; otherwise timeout duration typically in seconds via context sourceFilePath = fully qualified source file path and name to upload targetKey = the actual key name without any parts with / indicating folder targetFolder = if the upload position is under one or more 'folder' sub-hierarchy, then specify the target folder names from left to right
Return Values:
location = value indicating the location where upload was persisted to on s3 bucket err = error encountered while attempting to upload
type S3ErrorResult ¶ added in v1.5.9
S3ErrorResult struct represents a Delete... batch operation error result