s3x

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjectURLer

type ObjectURLer func(string, string) string

ObjectURLer is a function that takes a key and returns the publicly accessible URL for that object

func AWSURLer

func AWSURLer(region string) ObjectURLer

func MinioURLer

func MinioURLer(endpoint string) ObjectURLer

type Service

type Service struct {
	Client *s3.Client
	// contains filtered or unexported fields
}

Service is simple abstraction layer to work with a S3-compatible storage service

func NewService

func NewService(accessKey, secretKey, region, endpoint string, minio bool) (*Service, error)

NewService creates a new S3 service with the given credentials and configuration

func (*Service) BatchPut

func (s *Service) BatchPut(ctx context.Context, us []*Upload, workers int) error

BatchPut writes the entire batch of items to the passed in URLs, returning a map of errors if any. Writes will be retried up to three times automatically.

func (*Service) EmptyBucket

func (s *Service) EmptyBucket(ctx context.Context, bucket string) error

EmptyBucket is a convenience method to delete all the objects in a bucket

func (*Service) GetObject

func (s *Service) GetObject(ctx context.Context, bucket, key string) (string, []byte, error)

GetObject is a convenience method to get an object from S3 and read its contents into a byte slice

func (*Service) ObjectURL

func (s *Service) ObjectURL(bucket, key string) string

ObjectURL returns the publicly accessible URL for the given object

func (*Service) PutObject

func (s *Service) PutObject(ctx context.Context, bucket, key string, contentType string, body []byte, acl types.ObjectCannedACL) (string, error)

PutObject is a convenience method to put the given object and return its publicly accessible URL

func (*Service) Test

func (s *Service) Test(ctx context.Context, bucket string) error

Test is a convenience method to HEAD a bucket to test if it exists and we can access it

type Upload

type Upload struct {
	Bucket      string
	Key         string
	ContentType string
	Body        []byte
	ACL         types.ObjectCannedACL

	// set by BatchPut
	URL   string
	Error error
}

Upload is our type for a file in a batch upload

Jump to

Keyboard shortcuts

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