s3

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyBucketName = errors.New("empty bucket name")
	ErrEmptyFilePath   = errors.New("empty file path")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	AccessID   string `validate:"required" secret:"true"`
	SecretKey  string `validate:"required" secret:"true"`
	BucketName string `validate:"required"`
	Token      string `secret:"true" usage:"used only for amazon s3"`
	Region     string `validate:"required" example:"ru-1"`
	Endpoint   string `validate:"required"`
}

type ListItem

type ListItem struct {
	Path         string
	LastModified *time.Time
	Size         *int64
}

type S3

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

S3 ...

func New

func New(ctx context.Context, l logger.Logger, cfg Config) (*S3, error)

New ...

func (*S3) BucketExists

func (s *S3) BucketExists(ctx context.Context, bucketName string) (bool, error)

func (*S3) CreateBucket

func (s *S3) CreateBucket(ctx context.Context, bucketName string) error

func (*S3) Delete

func (s *S3) Delete(ctx context.Context, bucketName string, filePaths []string) error

Delete - Delete directory with files from s3 bucket

func (*S3) DeleteBucket

func (s *S3) DeleteBucket(ctx context.Context, bucketName string) error

func (*S3) Download

func (s *S3) Download(ctx context.Context, bucketName, filePath string) ([]byte, error)

Download file from s3 bucket

func (*S3) Exists

func (s *S3) Exists(ctx context.Context, bucketName, filePath string) (bool, error)

Download file from s3 bucket

func (*S3) List

func (s *S3) List(ctx context.Context, bucketName string) ([]ListItem, error)

List ...

func (*S3) ListBuckets

func (s *S3) ListBuckets(ctx context.Context) ([]types.Bucket, error)

func (*S3) Upload

func (s *S3) Upload(ctx context.Context, bucketName, filePath string, content []byte) (string, error)

Upload file to s3 bucket

func (*S3) UploadStream

func (s *S3) UploadStream(ctx context.Context, bucketName, filePath string, reader io.Reader) (string, error)

Upload file to s3 bucket

Jump to

Keyboard shortcuts

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