s3

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACLAuthenticatedRead = "authenticated-read"
	ACLPrivate           = "private"
	ACLPublicRead        = "public-read"
	ACLPublicReadWrite   = "public-read-write"
)

ACL settings

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

Bucket is S3 Bucket wrapper struct.

func NewBucket

func NewBucket(svc *S3, name string) *Bucket

NewBucket returns initialized *Bucket.

func (*Bucket) AddObject

func (b *Bucket) AddObject(obj *PutObject, path string)

AddObject adds object to write spool (w/ public read access).

func (*Bucket) AddSecretObject

func (b *Bucket) AddSecretObject(obj *PutObject, path string)

AddSecretObject adds object to write spool (w/ ACL permission).

func (*Bucket) DeleteObject

func (b *Bucket) DeleteObject(path string) error

DeleteObject deletes the object of target path.

func (*Bucket) GetObjectByte

func (b *Bucket) GetObjectByte(path string) ([]byte, error)

GetObjectByte returns bytes of object from given S3 path.

func (*Bucket) GetSecretURL

func (b *Bucket) GetSecretURL(path string) (string, error)

GetSecretURL fetches a url of target S3 object w/ ACL permission.

func (*Bucket) GetSecretURLWithExpire

func (b *Bucket) GetSecretURLWithExpire(path string, expire int) (string, error)

GetSecretURLWithExpire fetches a url of target S3 object w/ ACL permission (url expires in `expire` value seconds) ** this isn't work **

func (*Bucket) GetURL

func (b *Bucket) GetURL(path string) string

GetURL fetches url of target S3 object.

func (*Bucket) HeadObject

func (b *Bucket) HeadObject(path string) (*SDK.HeadObjectOutput, error)

HeadObject executes HeadObject operation.

func (*Bucket) IsExists

func (b *Bucket) IsExists(path string) bool

IsExists checks if an object exists on the given path.

func (*Bucket) PutAll

func (b *Bucket) PutAll() error

PutAll executes PutObject operation in the put spool.

func (*Bucket) PutOne

func (b *Bucket) PutOne(obj *PutObject, path, acl string) error

PutOne executes PutObject operation in the put spool.

func (*Bucket) SetExpire

func (b *Bucket) SetExpire(sec int)

SetExpire sets default expire sec for ACL access.

type PutObject

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

PutObject is wrapper struct for the object to upload S3.

func NewPutObject

func NewPutObject(file *os.File) *PutObject

NewPutObject returns initialized *PutObject from File.

func NewPutObjectCopy

func NewPutObjectCopy(file *os.File) *PutObject

NewPutObjectCopy returns initialized *PutObject from File and copy byte data.

func NewPutObjectString

func NewPutObjectString(s string) *PutObject

NewPutObjectString returns initialized *PutObject from string.

func (*PutObject) Content

func (o *PutObject) Content() io.ReadSeeker

Content returns the content of the Object.

func (*PutObject) FileType

func (o *PutObject) FileType() string

FileType returns file type of the content.

func (*PutObject) SetTypeAsText

func (o *PutObject) SetTypeAsText()

SetTypeAsText sets MIME type as text file.

func (*PutObject) Size

func (o *PutObject) Size() int64

Size returns size of the content.

func (*PutObject) String

func (o *PutObject) String() string

type S3

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

S3 has S3 client and bucket list.

func New

func New(conf config.Config) (*S3, error)

New returns initialized *S4.

func (*S3) CreateBucket

func (svc *S3) CreateBucket(in *SDK.CreateBucketInput) error

CreateBucket creates new S3 bucket.

func (*S3) CreateBucketWithName

func (svc *S3) CreateBucketWithName(name string) error

CreateBucketWithName creates new S3 bucket by given name.

func (*S3) Errorf

func (svc *S3) Errorf(format string, v ...interface{})

Errorf logging error information.

func (*S3) ForceDeleteBucket

func (svc *S3) ForceDeleteBucket(name string) error

ForceDeleteBucket deletes S3 bucket by given name.

func (*S3) GetBucket

func (svc *S3) GetBucket(bucket string) (*Bucket, error)

GetBucket gets S3 bucket.

func (*S3) Infof

func (svc *S3) Infof(format string, v ...interface{})

Infof logging information.

func (*S3) IsExistBucket

func (svc *S3) IsExistBucket(name string) (bool, error)

IsExistBucket checks if the Bucket already exists or not.

func (*S3) SetLogger

func (svc *S3) SetLogger(logger log.Logger)

SetLogger sets logger.

Jump to

Keyboard shortcuts

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