s3

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package s3 implements a s3-backed object store

Index

Constants

View Source
const DefaultURLExpiration = time.Hour * 24

DefaultURLExpiration Default expiration for the presigned download URLs. After this time attempts to download the object will fail TODO: check this default (AWS default is 900 seconds)

Variables

This section is empty.

Functions

func New

func New(conf Config) (store.ObjectStore, error)

New creates an object store backed by a S3 bucket

func WithExpiration

func WithExpiration(exp time.Duration) func(*s3.PresignOptions)

WithExpiration sets the expiration for the presigned URL

Types

type Config

type Config struct {
	// Name of the S3 bucket
	Bucket string
	// S3 Client
	Client *s3.Client
	// AWS endpoint (used for testing)
	Endpoint string
	// AWS Region
	Region string
	// Expiration for the presigned download URLs
	URLExpiration time.Duration
}

Config S3 Store configuration

type Store

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

Store a ObjectStore backed by a S3 bucket

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (store.Object, error)

Get retrieves an objects if exists in the object store or an error otherwise

func (*Store) Put

func (s *Store) Put(ctx context.Context, id string, content io.Reader) (store.Object, error)

Put stores the object and returns the metadata Fails if the object already exists

Jump to

Keyboard shortcuts

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