s3

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package s3 provides the Amazon S3 disk implementation.

Index

Constants

View Source
const (
	// Provider is the provider name for Amazon S3.
	Provider = "s3"
)

Variables

This section is empty.

Functions

func NewAutoWire added in v0.3.0

func NewAutoWire(ctx context.Context, cfg map[string]interface{}) (godrive.Disk, error)

NewAutoWire creates a new Amazon S3 disk from an autowire configuration.

func Register added in v0.3.0

func Register(cfg *godrive.AutoWireConfig)

Register registeres Amazon S3 as a provider for the disk autowire.

Types

type Config

type Config struct {
	Bucket string
	Region string
	Public bool
}

Config is the disk configuration.

type Disk

type Disk struct {
	Client *s3.Client
	Config Config
}

Disk is the Amazon S3 disk.

func NewDisk

func NewDisk(client *s3.Client, region, bucket string, options ...Option) *Disk

NewDisk creates a new Amazon S3 disk.

func (*Disk) Delete

func (d *Disk) Delete(ctx context.Context, key string) error

Delete deletes the file with the given key.

func (*Disk) Get

func (d *Disk) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves the file with the given key.

func (*Disk) GetURL

func (d *Disk) GetURL(_ context.Context, key string) (string, error)

GetURL returns the public URL for the file at path.

func (*Disk) Put

func (d *Disk) Put(ctx context.Context, key string, b []byte) error

Put writes b to the file with the given key.

func (*Disk) PutReader added in v0.5.0

func (d *Disk) PutReader(ctx context.Context, key string, r io.Reader) error

PutReader writes b to the file with the given key.

type InvalidConfigValueError added in v0.3.0

type InvalidConfigValueError struct {
	Key     string
	Details string
}

InvalidConfigValueError means the autowire configuration has an invalid config value.

func (InvalidConfigValueError) Error added in v0.3.0

func (err InvalidConfigValueError) Error() string

type Option

type Option func(*Config)

Option is a disk configuration option.

func Public

func Public(public bool) Option

Public configures the disk to make all uploaded files publicly accessible.

Jump to

Keyboard shortcuts

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