storage

package
v0.0.0-...-033a009 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewS3Client

func NewS3Client(opt Options) *s3.S3

NewS3Client returns connfigured AWS S3 client

Types

type ACL

type ACL string

ACL permission

const (
	Public  ACL = "public-read"
	Private ACL = "private"
)

Predefined ACL permissions

func (ACL) String

func (a ACL) String() string

type Client

type Client interface {
	PutObject(input *s3.PutObjectInput) (*s3.PutObjectOutput, error)
	GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error)
	DeleteObject(input *s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error)
}

Client interface

type Interactor

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

Interactor struct

func New

func New(c Client, opt Options) *Interactor

New is a factory function, returns a new instance of the storage interactor

func (*Interactor) Download

func (i *Interactor) Download(filepath string) (io.ReadCloser, *string, error)

Download file from the cloud storage

func (*Interactor) FilePath

func (i *Interactor) FilePath(filename string) string

FilePath returns absolute file path in the storage

func (*Interactor) FileURL

func (i *Interactor) FileURL(filepath string) string

FileURL return public url for a file

func (*Interactor) Remove

func (i *Interactor) Remove(filepath string) error

Remove file from the cloud storage

func (*Interactor) Upload

func (i *Interactor) Upload(file io.ReadSeeker, filepath string, acl ACL, contentType string) error

Upload file to the cloud storage

type Options

type Options struct {
	Key            string
	Secret         string
	Endpoint       string
	Region         string
	Bucket         string
	URL            string
	ForcePathStyle bool
	DisableSSL     bool
}

Options struct

type S3Mock

type S3Mock struct {
	Error       error
	Filepath    string
	ContentType string
}

S3Mock struct

func (*S3Mock) DeleteObject

func (s *S3Mock) DeleteObject(input *s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error)

DeleteObject ...

func (*S3Mock) GetObject

func (s *S3Mock) GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error)

GetObject ...

func (*S3Mock) PutObject

func (s *S3Mock) PutObject(input *s3.PutObjectInput) (*s3.PutObjectOutput, error)

PutObject ...

Jump to

Keyboard shortcuts

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