s3

package
v0.0.0-...-7139136 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

README

Use with local S3 server

@link https://docs.min.io

docker run --rm -p 9000:9000 \
  -e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" \
  -e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
  minio/minio server /data

Documentation

Overview

Package s3 implements file storage collection with S3 driver support

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCredentials    = errors.New("[s3] you need to set BOTH AccessKeyID AND SecretAccessKey")
	ErrInvalidBucketManifest = errors.New("[s3] back manifest object is invalid")
)

Errors list

View Source
var (
	ErrUnsupportedContentType   = errors.New("content-type is not supported")
	ErrCustomObjectIDIsNotValid = errors.New("invalid custom object ID or taken")
)

Errors list...

Functions

This section is empty.

Types

type Options

type Options func(conf *optionConfig) error

Options configuration type

func WithFilepathGenerator

func WithFilepathGenerator(pattern string) Options

WithFilepathGenerator updates path generator option

func WithMainBucket

func WithMainBucket(backetName string) Options

WithMainBucket which makes that all objects will be stored in the subdirectory {bucketName}.server.com/{objectPath}

func WithS3Config

func WithS3Config(f func(*aws.Config) *aws.Config) Options

WithS3Config custom configurator

func WithS3Credentionals

func WithS3Credentionals(accessKeyID, secretAccessKey string) Options

WithS3Credentionals to the server

func WithS3FromURL

func WithS3FromURL(connect string) Options

WithS3FromURL parse URL and fill the S3 config

type Storage

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

Storage to manage S3 type

func NewStorage

func NewStorage(options ...Options) (*Storage, error)

NewStorage object returns storage according to options

func (*Storage) Clean

func (c *Storage) Clean(ctx context.Context, id npio.ObjectID) error

Clean removes all subfiles from object except original and manifest

func (*Storage) Create

func (c *Storage) Create(ctx context.Context, bucket string, id npio.ObjectID, overwrite bool, params url.Values) (npio.Object, error)

Create new file object

func (*Storage) Open

func (c *Storage) Open(ctx context.Context, id npio.ObjectID) (_ npio.Object, err error)

Open exixting file

func (*Storage) Read

func (c *Storage) Read(ctx context.Context, id npio.ObjectID, name string) (io.ReadCloser, error)

Read returns reader of the specific internal object

func (*Storage) ReadManifest

func (c *Storage) ReadManifest(ctx context.Context, bucket string) (*models.Manifest, error)

ReadManifest information method

func (*Storage) Remove

func (c *Storage) Remove(ctx context.Context, id npio.ObjectID, names ...string) error

Remove file from directory by name without extension of file

func (*Storage) Scan

func (c *Storage) Scan(ctx context.Context, pattern string, walkf npio.WalkStorageFnk) error

Scan storage by pattern

pattern: search type equals to glob https://golang.org/pkg/path/filepath/#Glob

func (*Storage) Update

func (c *Storage) Update(ctx context.Context, id npio.ObjectID, name string, reader io.Reader, meta *models.ItemMeta) error

Upload data as file

func (*Storage) UpdateManifest

func (c *Storage) UpdateManifest(ctx context.Context, bucket string, manifest *models.Manifest) error

UpdateManifest information method

func (*Storage) UpdateMeta

func (c *Storage) UpdateMeta(ctx context.Context, id npio.ObjectID, name string, meta *models.ItemMeta) error

Update data in the storage

func (*Storage) UpdatePatams

func (c *Storage) UpdatePatams(ctx context.Context, id npio.ObjectID, params url.Values) error

UpdatePatams in the object. If name is present then update only params linked with the subobject

Jump to

Keyboard shortcuts

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