Skip to content

Commit

Permalink
document: add s3 options comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtwinkle committed Aug 19, 2024
1 parent 1e1de23 commit f57f4f8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions aws/awss3/options/s3download/s3_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type OptionS3Download interface {
}

type confS3Download struct {
// Sets the function used to replace file names in downloaded files.
FileNameReplacer FileNameReplacerFunc
}

Expand All @@ -15,6 +16,8 @@ func (o OptionFileNameReplacer) Apply(c *confS3Download) {
c.FileNameReplacer = FileNameReplacerFunc(o)
}

// WithFileNameReplacerFunc
// Sets the function used to replace file names in downloaded files.
func WithFileNameReplacerFunc(fileNameReplacerFunc FileNameReplacerFunc) OptionFileNameReplacer {
return OptionFileNameReplacer(fileNameReplacerFunc)
}
Expand Down
13 changes: 13 additions & 0 deletions aws/awss3/options/s3head/s3_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func (o OptionTimeout) Apply(c *confS3Head) {
c.Timeout = time.Duration(o)
}

// WithTimeout
// Timeout can specify the number of seconds to wait when using a waiter
// to check for the existence of an object.
func WithTimeout(duration time.Duration) OptionTimeout {
return OptionTimeout(duration)
}
Expand All @@ -41,6 +44,10 @@ func (o OptionMinDelay) Apply(c *confS3Head) {
c.MinDelay = time.Duration(o)
}

// WithMinDelay
// MinDelay is the minimum amount of time to delay between retries. If unset,
// ObjectExistsWaiter will use default minimum delay of 5 seconds. Note that
// MinDelay must resolve to a value lesser than or equal to the MaxDelay.
func WithMinDelay(minDelay time.Duration) OptionMinDelay {
return OptionMinDelay(minDelay)
}
Expand All @@ -51,6 +58,10 @@ func (o OptionMaxDelay) Apply(c *confS3Head) {
c.MaxDelay = time.Duration(o)
}

// WithMaxDelay
// MaxDelay is the maximum amount of time to delay between retries. If unset or set
// to zero, ObjectExistsWaiter will use default max delay of 120 seconds. Note that
// MaxDelay must resolve to value greater than or equal to the MinDelay.
func WithMaxDelay(maxDelay time.Duration) OptionMaxDelay {
return OptionMaxDelay(maxDelay)
}
Expand All @@ -61,6 +72,8 @@ func (o OptionLogWaitAttempts) Apply(c *confS3Head) {
c.LogWaitAttempts = bool(o)
}

// WithLogWaitAttempts
// LogWaitAttempts is used to enable logging for waiter retry attempts
func WithLogWaitAttempts(logWaitAttempts bool) OptionLogWaitAttempts {
return OptionLogWaitAttempts(logWaitAttempts)
}
Expand Down
10 changes: 10 additions & 0 deletions aws/awss3/options/s3list/s3_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ type OptionS3List interface {
}

type confS3List struct {
// https://github.com/aws/aws-sdk-go-v2/blob/v1.30.4/service/s3/api_op_ListObjectsV2.go#L201-L205
// Limits the response to keys that begin with the specified prefix.
//
// Directory buckets - For directory buckets, only prefixes that end in a
// delimiter ( / ) are supported.
Prefix *string
}

Expand All @@ -16,6 +20,12 @@ func (o OptionPrefix) Apply(c *confS3List) {
c.Prefix = &v
}

// WithPrefix
// https://github.com/aws/aws-sdk-go-v2/blob/v1.30.4/service/s3/api_op_ListObjectsV2.go#L201-L205
// Limits the response to keys that begin with the specified prefix.
//
// Directory buckets - For directory buckets, only prefixes that end in a
// delimiter ( / ) are supported.
func WithPrefix(prefix string) OptionPrefix {
return OptionPrefix(prefix)
}
Expand Down
19 changes: 17 additions & 2 deletions aws/awss3/options/s3presigned/s3_presigned.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ type OptionS3Presigned interface {
}

type confS3Presigned struct {
// ContentDispositionType is the type of the Content-Disposition header.
ContentDispositionType ContentDispositionType
PresignExpires time.Duration
PresignFileName string
// PresignExpires is the duration that the presigned URL will be valid for.
PresignExpires time.Duration
// PresignFileName is the name of the file that will be returned in the Content-Disposition header.
PresignFileName string
}
type ContentDispositionType int

const (
// ContentDispositionTypeAttachment is the Content-Disposition header type for attachment.
// default value, indicating it should be downloaded; most browsers presenting a 'Save as' dialog,
// prefilled with the value of the filename parameters if present.
ContentDispositionTypeAttachment ContentDispositionType = iota
// ContentDispositionTypeInline is the Content-Disposition header type for inline.
// indicating it can be displayed inside the Web page, or as the Web page.
ContentDispositionTypeInline
)

Expand All @@ -36,6 +44,9 @@ func (o OptionPresignFileName) Apply(c *confS3Presigned) {
c.PresignFileName = string(o)
}

// WithPresignFileName
// PresignFileName is the name of the file that will be returned in the Content-Disposition header.
// If set, the Content-Disposition header must be set to ContentDispositionTypeAttachment.
func WithPresignFileName(fileName string) OptionPresignFileName {
return OptionPresignFileName(fileName)
}
Expand All @@ -46,6 +57,8 @@ func (o OptionPresignExpires) Apply(c *confS3Presigned) {
c.PresignExpires = time.Duration(o)
}

// WithPresignExpires
// PresignExpires is the duration that the presigned URL will be valid for.
func WithPresignExpires(presignExpires time.Duration) OptionPresignExpires {
return OptionPresignExpires(presignExpires)
}
Expand All @@ -56,6 +69,8 @@ func (o OptionContentDispositionType) Apply(c *confS3Presigned) {
c.ContentDispositionType = ContentDispositionType(o)
}

// WithContentDispositionType
// ContentDispositionType is the type of the Content-Disposition header.
func WithContentDispositionType(tp ContentDispositionType) OptionContentDispositionType {
return OptionContentDispositionType(tp)
}

0 comments on commit f57f4f8

Please sign in to comment.