s3

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

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) 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) 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

Jump to

Keyboard shortcuts

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