s3

package
v0.0.0-...-777b0ca Latest Latest
Warning

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

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

Documentation

Overview

Package s3 provides a storage implementation for S3

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringPointer

func StringPointer(s string) *string

Types

type Config

type Config struct {
	// Enabled is a flag to enable or disable the storage
	Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
	// AccessKeyID is the access key id
	AccessKeyID string `json:"accessKeyID" koanf:"accessKeyID"`
	// Bucket is the name of the bucket
	Bucket string `json:"bucket" koanf:"bucket" default:"yourbucketname"`
	// Endpoint is the endpoint to use for the s3 client
	Endpoint string `json:"endpoint" koanf:"endpoint"`
	// Region is the region to use for the s3 client
	Region string `json:"region" koanf:"region" default:"us-region-a"`
	// SecretAccessKey is the secret access key
	SecretAccessKey string `json:"secretAccessKey" koanf:"secretAccessKey"`
	// UploadConcurrency is the number of goroutines to spin up when uploading parts
	UploadConcurrency *int64 `json:"uploadConcurrency" koanf:"uploadConcurrency" default:"5"`
	// CustomHTTPClient is a custom http client wrapper for s3 interfaces
	CustomHTTPClient CustomAPIHTTPClient `json:"-" koanf:"-"`
}

Config is the configuration for Storage

type CustomAPIHTTPClient

type CustomAPIHTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

CustomAPIHTTPClient is a custom http client wrapper for s3 interfaces

type Storage

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

Storage wraps AWS S3 storage interface and s3 client pointer

func NewStorage

func NewStorage(cfg Config, keyNamespace string) (*Storage, error)

NewStorage returns a new Storage with the provided configuration

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context, path string) error

Delete deletes path which uses the configured bucket and takes path as input

func (*Storage) FileSystem

func (s *Storage) FileSystem() *afero.Afero

FileSystem returns the underlying afero filesystem

func (*Storage) Open

func (s *Storage) Open(ctx context.Context, path string) (io.ReadCloser, error)

Open opens path for reading and returns a reader which can be used to read the content

func (*Storage) OpenWithStat

func (s *Storage) OpenWithStat(ctx context.Context, path string) (io.ReadCloser, *storage.Stat, error)

OpenWithStat opens the provided path for reading with file stats included

func (*Storage) PresignedURL

func (s *Storage) PresignedURL(key string, contentType string) (string, error)

PresignedURL returns a URL that provides access to a file for 15 minutes

func (*Storage) Save

func (s *Storage) Save(ctx context.Context, content io.Reader, path, checksum, key string, tags *string) error

Save saves content to path inside of a bucket (bucket is set in the config)

func (*Storage) SaveQuick

func (s *Storage) SaveQuick(ctx context.Context, content io.Reader, path string) error

Save saves content to path inside of a bucket (bucket is set in the config)

func (*Storage) Stat

func (s *Storage) Stat(ctx context.Context, path string) (*storage.Stat, error)

Stat returns metadata about the object found in the provided path

func (*Storage) Tags

func (s *Storage) Tags(key string) (map[string]string, error)

Tags returns the tags for a specified key

func (*Storage) TempFileSystem

func (s *Storage) TempFileSystem() *afero.Afero

TempFileSystem returns the temporary afero filesystem

Jump to

Keyboard shortcuts

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