-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
verzcar
committed
Oct 15, 2023
1 parent
2ab0eea
commit c16cbe8
Showing
4 changed files
with
63 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package awsx | ||
|
||
type S3Option func(bd *S3RequestConfig) | ||
|
||
func applyS3Options(options []S3Option) *S3RequestConfig { | ||
req := &S3RequestConfig{} | ||
|
||
for _, option := range options { | ||
option(req) | ||
} | ||
return req | ||
} | ||
|
||
func AccessKeyID(id string) S3Option { | ||
return func(req *S3RequestConfig) { | ||
req.accessKeyID = id | ||
} | ||
} | ||
|
||
func AccessKeySecret(secret string) S3Option { | ||
return func(req *S3RequestConfig) { | ||
req.accessKeySecret = secret | ||
} | ||
} | ||
|
||
func Region(region string) S3Option { | ||
return func(req *S3RequestConfig) { | ||
req.region = region | ||
} | ||
} | ||
|
||
func DefaultBucketName(name string) S3Option { | ||
return func(req *S3RequestConfig) { | ||
req.defaultBucketName = name | ||
} | ||
} | ||
|
||
func UploadTimeout(timeout int) S3Option { | ||
return func(req *S3RequestConfig) { | ||
req.uploadTimeout = timeout | ||
} | ||
} | ||
|
||
func DefaultBaseURL(url string) S3Option { | ||
return func(req *S3RequestConfig) { | ||
req.defaultBaseURL = url | ||
} | ||
} |