aws

package
v0.0.0-...-d4a7eef Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegionAuto = "auto"

	S3DefaultAccessKey = ""
	S3DefaultSecretKey = ""
)

Variables

This section is empty.

Functions

func NewGlobalHelper

func NewGlobalHelper(opts ...Option) error

Types

type Helper

type Helper struct {
	AwsS3Client *s3.Client

	S3Client
	S3PresignedClient

	Options
}

func GetGlobalHelper

func GetGlobalHelper() *Helper

func NewHelper

func NewHelper(opts ...Option) (*Helper, error)

func (*Helper) CreateBucket

func (h *Helper) CreateBucket(opts s3.CreateBucketInput) (*s3.CreateBucketOutput, error)

func (*Helper) DeleteObject

func (h *Helper) DeleteObject(bucket, key string) error

func (*Helper) GenPresignedUrl

func (h *Helper) GenPresignedUrl(bucket, key string, expires time.Duration) (string, error)

func (*Helper) PutByteObject

func (h *Helper) PutByteObject(bucket, key string, body []byte) (*s3.PutObjectOutput, error)

func (*Helper) PutObject

func (h *Helper) PutObject(bucket, key string, reader io.Reader) (*s3.PutObjectOutput, error)

func (*Helper) SetS3Client

func (h *Helper) SetS3Client() error

type Option

type Option func(*Options)

func AccessKey

func AccessKey(accessKey string) Option

func EnableCustomURL

func EnableCustomURL(enable bool) Option

func EnableStaticCreds

func EnableStaticCreds(enable bool) Option

func InsecureSkipVerify

func InsecureSkipVerify(skip bool) Option

func Region

func Region(region string) Option

func S3Url

func S3Url(s3Url string) Option

func SecretKey

func SecretKey(secretKey string) Option

type Options

type Options struct {
	Region string `json:"region" yaml:"region"`
	S3Url  string `json:"s3Url" yaml:"s3Url"`

	AccessKey string `json:"accessKey" yaml:"accessKey"`
	SecretKey string `json:"secretKey" yaml:"secretKey"`

	EnableCustomURL    bool `json:"enableCustomURL" yaml:"enableCustomURL"`
	EnableStaticCreds  bool `json:"enableStaticCreds" yaml:"enableStaticCreds"`
	InsecureSkipVerify bool `json:"insecureSkipVerify" yaml:"insecureSkipVerify"`
}
var (
	Opts *Options
)

type S3Client

type S3Client interface {
	CreateBucket(context.Context, *s3.CreateBucketInput, ...func(*s3.Options)) (*s3.CreateBucketOutput, error)
	PutObject(context.Context, *s3.PutObjectInput, ...func(*s3.Options)) (*s3.PutObjectOutput, error)
	DeleteObject(context.Context, *s3.DeleteObjectInput, ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)
}

type S3PresignedClient

type S3PresignedClient interface {
	PresignGetObject(context.Context, *s3.GetObjectInput, ...func(*s3.PresignOptions)) (*v4.PresignedHTTPRequest, error)
}

Jump to

Keyboard shortcuts

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