s3

package
v1.101.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package s3 provides a simple and basic wrapper client for interacting with an AWS S3 bucket. It includes the ability to upload, download, and delete objects.

This package is based on github.com/aws/aws-sdk-go-v2/service/s3 and abstracts away the complexities of the S3 protocol, providing a simplified interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a wrapper for the S3 client in the AWS SDK.

func New

func New(ctx context.Context, bucketName string, opts ...Option) (*Client, error)

New creates a new instance of the S3 client wrapper.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string) error

Delete removes an object from S3 Bucket by key.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (*Object, error)

Get returns *Object.

func (*Client) ListKeys

func (c *Client) ListKeys(ctx context.Context, prefix string) ([]string, error)

ListKeys searches for keys by a provided prefix; returns all keys if prefix is empty string.

func (*Client) Put

func (c *Client) Put(ctx context.Context, key string, reader io.Reader) error

Put uploads data from reader to S3 Bucket.

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object represents object retrieved from S3.

type Option

type Option func(*cfg)

Option is a type to allow setting custom client options.

func WithAWSOptions

func WithAWSOptions(opt awsopt.Options) Option

WithAWSOptions allows to add an arbitrary AWS options.

func WithEndpointImmutable added in v1.91.0

func WithEndpointImmutable(url string) Option

WithEndpointImmutable sets an immutable endpoint.

func WithEndpointMutable added in v1.91.0

func WithEndpointMutable(url string) Option

WithEndpointMutable sets a mutable endpoint.

func WithSrvOptionFuncs added in v1.91.0

func WithSrvOptionFuncs(opt ...SrvOptionFunc) Option

WithSrvOptionFuncs allows to specify specific options.

type S3

type S3 interface {
	DeleteObject(ctx context.Context, params *s3.DeleteObjectInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)
	GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)
	ListObjectsV2(ctx context.Context, params *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
	PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
}

S3 represents the mockable functions in the AWS SDK S3 client.

type SrvOptionFunc added in v1.91.0

type SrvOptionFunc = func(*s3.Options)

SrvOptionFunc is an alias for this service option function.

Jump to

Keyboard shortcuts

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