us3

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjectInfo

type ObjectInfo struct {
	Bucket        string
	Key           string
	ContentLength int64
	ETag          string
	Sha256Sum     string
	LastModified  time.Time
}

type Option

type Option func(ctx context.Context, cfg *s3Config) error

func WithAssumeRole

func WithAssumeRole(roleARN string, externalID string) Option

WithAssumeRole allows you to assume an external role to perform actions. It can be specified multiple times, and the specified roles will be assumed in order.

func WithCredentials

func WithCredentials(accessKeyID string, secretAccessKey string) Option

WithCredentials configures an AWS S3 access key and secret access key for the s3config.

func WithCustomEndpoint

func WithCustomEndpoint(endpointURL string) Option

WithCustomEndpoint sets a custom AWS S3 endpoint URL for the s3Config.

func WithMaxDownloadFilesize

func WithMaxDownloadFilesize(maxFileSize int64) Option

WithMaxDownloadFilesize limits the maximum number of bytes that a file is allowed to have in order to be uploaded or downloaded. Any values greater than or less than zero results in no limit.

func WithRegion

func WithRegion(region string) Option

WithRegion sets an AWS S3 region for the s3Config.

type S3BucketConfig

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

type S3Client

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

func NewClient

func NewClient(ctx context.Context, bucketName string, opts ...Option) (*S3Client, error)

NewClient creates a new AWS S3 client.

func NewClientFromURI

func NewClientFromURI(ctx context.Context, uri string) (string, *S3Client, error)

NewClientFromURI parses an s3://bucket/uri and creates a client. It also returns the key specified in the URI.

func (*S3Client) BucketName added in v0.0.21

func (s *S3Client) BucketName(ctx context.Context) string

func (*S3Client) Get

func (s *S3Client) Get(ctx context.Context, key string) (io.Reader, error)

Get downloads a file from AWS S3.

func (*S3Client) ListObjects

func (s *S3Client) ListObjects(ctx context.Context) ([]string, error)

ListObjects lists all the objects in the AWS S3 bucket.

func (*S3Client) ObjectInfo

func (s *S3Client) ObjectInfo(ctx context.Context, key string) (*ObjectInfo, error)

ObjectInfo returns the object info from AWS S3.

func (*S3Client) Put

func (s *S3Client) Put(ctx context.Context, key string, r io.Reader, contentType string) error

Put uploads a file to AWS S3.

func (*S3Client) ValidateBucket

func (s *S3Client) ValidateBucket(ctx context.Context) error

ValidateBucket calls HeadBucket to ensure that the bucket exists and we have proper access.

type Upload

type Upload struct {
	Data        []byte
	ContentType string
}

Jump to

Keyboard shortcuts

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