s3

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 14 Imported by: 1

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 added in v1.0.0

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) AddPrivateObject added in v1.16.5

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

AddPrivateObject adds object to write spool (w/ Private).

func (*Bucket) AddSecretObject

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

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

func (*Bucket) CopyFrom added in v1.14.1

func (b *Bucket) CopyFrom(srcBucket, srcPath, destPath string, opt ...CopyObjectRequest) (CopyObjectResponse, error)

CopyFrom copies an object from source buckwt and path.

func (*Bucket) CopyTo added in v1.14.1

func (b *Bucket) CopyTo(srcPath, destBucket, destPath string, opt ...CopyObjectRequest) (CopyObjectResponse, error)

CopyTo copies an object to destination bucket and path.

func (*Bucket) DeleteObject

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

DeleteObject deletes the object of target path.

func (*Bucket) DeleteObjectWithVersionID added in v1.16.3

func (b *Bucket) DeleteObjectWithVersionID(path string, versionID string) error

DeleteObjectWithVersionID deletes the object of target path and versionId.

func (*Bucket) GetObjectByte

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

GetObjectByte returns bytes of object from given S3 path.

func (*Bucket) GetObjectVersionID added in v1.16.4

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

GetObjectVersionID returns versionID 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 added in v1.4.2

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

HeadObject executes HeadObject operation.

func (*Bucket) IsExists added in v1.4.2

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

IsExists checks if an object exists on the given path.

func (*Bucket) ListAllObjects added in v1.14.1

func (b *Bucket) ListAllObjects(prefix string) ([]Object, error)

ListAllObjects fetches a list of all of the objects in the bucket and prefix.

func (*Bucket) ListObjectsV2 added in v1.14.1

func (b *Bucket) ListObjectsV2(opt ...ListObjectsRequest) (ListObjectsResponse, error)

ListObjectsV2 executes ListObjectsV2 operation.

func (*Bucket) PutAll added in v1.0.0

func (b *Bucket) PutAll() error

PutAll executes PutObject operation in the put spool.

func (*Bucket) PutOne added in v1.0.0

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

PutOne executes PutObject operation in the put spool.

func (*Bucket) SetExpire added in v1.0.0

func (b *Bucket) SetExpire(sec int)

SetExpire sets default expire sec for ACL access.

type CopyObjectRequest added in v1.14.1

type CopyObjectRequest struct {
	SrcBucket  string
	SrcPath    string
	DestBucket string
	DestPath   string
	// if true, add prefix to bucket name
	UseSamePrefix bool

	// optional params
	// ref: https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html
	ACL                            string
	CacheControl                   string
	ContentDisposition             string
	ContentEncoding                string
	ContentLanguage                string
	ContentType                    string
	CopySourceIfMatch              string
	CopySourceIfModifiedSince      time.Time
	CopySourceIfNoneMatch          string
	CopySourceIfUnmodifiedSince    time.Time
	CopySourceSSECustomerAlgorithm string
	CopySourceSSECustomerKey       string
	CopySourceSSECustomerKeyMD5    string
	Expires                        time.Time
	GrantFullControl               string
	GrantRead                      string
	GrantReadACP                   string
	GrantWriteACP                  string
	Metadata                       map[string]string
	MetadataDirective              string
	ObjectLockLegalHoldStatus      string
	ObjectLockMode                 string
	ObjectLockRetainUntilDate      time.Time
	RequestPayer                   string
	SSECustomerAlgorithm           string
	SSECustomerKey                 string
	SSECustomerKeyMD5              string
	SSEKMSEncryptionContext        string
	SSEKMSKeyID                    string
	ServerSideEncryption           string
	StorageClass                   string
	Tagging                        string
	TaggingDirective               string
	WebsiteRedirectLocation        string
}

CopyObjectRequest has parameters for `CopyObject` operation.

func (CopyObjectRequest) ToInput added in v1.14.1

func (r CopyObjectRequest) ToInput() *SDK.CopyObjectInput

type CopyObjectResponse added in v1.14.1

type CopyObjectResponse struct {
	ETag         string
	LastModified time.Time

	CopySourceVersionID     string
	Expiration              string
	RequestCharged          string
	SSECustomerAlgorithm    string
	SSECustomerKeyMD5       string
	SSEKMSEncryptionContext string
	SSEKMSKeyID             string
	ServerSideEncryption    string
	VersionID               string
}

CopyObjectResponse contains data from CopyObject.

func NewCopyObjectResponse added in v1.14.1

func NewCopyObjectResponse(out *SDK.CopyObjectOutput) CopyObjectResponse

type ListObjectsRequest added in v1.14.1

type ListObjectsRequest struct {
	Bucket string

	// optional
	ContinuationToken string
	Delimiter         string
	EncodingType      string
	FetchOwner        bool
	MaxKeys           int64
	Prefix            string
	RequestPayer      string
	StartAfter        string
}

ListObjectsRequest has parameters for `ListObjectsV2` operation.

func (ListObjectsRequest) ToInput added in v1.14.1

type ListObjectsResponse added in v1.14.1

type ListObjectsResponse struct {
	CommonPrefixes        []string
	Contents              []Object
	ContinuationToken     string
	Delimiter             string
	EncodingType          string
	IsTruncated           bool
	KeyCount              int64
	MaxKeys               int64
	Name                  string
	NextContinuationToken string
	Prefix                string
	StartAfter            string
}

ListObjectsResponse contains data from ListObjectsV2.

func NewListObjectsResponse added in v1.14.1

func NewListObjectsResponse(out *SDK.ListObjectsV2Output) ListObjectsResponse

type Object added in v1.14.1

type Object struct {
	ETag             string
	Key              string
	LastModified     time.Time
	Size             int64
	StorageClass     string
	OwnerID          string
	OwnerDisplayName string
}

func NewObject added in v1.14.1

func NewObject(d *SDK.Object) Object

type PutObject added in v1.0.0

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

PutObject is wrapper struct for the object to upload S3.

func NewPutObject added in v1.0.0

func NewPutObject(file *os.File) *PutObject

NewPutObject returns initialized *PutObject from File.

func NewPutObjectBytes added in v1.13.1

func NewPutObjectBytes(b []byte) *PutObject

NewPutObjectBytes returns initialized *PutObject from bytes.

func NewPutObjectCopy added in v1.0.0

func NewPutObjectCopy(file *os.File) *PutObject

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

func NewPutObjectString added in v1.0.0

func NewPutObjectString(s string) *PutObject

NewPutObjectString returns initialized *PutObject from string.

func (*PutObject) Content added in v1.0.0

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

Content returns the content of the Object.

func (*PutObject) FileType added in v1.0.0

func (o *PutObject) FileType() string

FileType returns file type of the content.

func (*PutObject) SetTypeAsText added in v1.0.0

func (o *PutObject) SetTypeAsText()

SetTypeAsText sets MIME type as text file.

func (*PutObject) Size added in v1.0.0

func (o *PutObject) Size() int64

Size returns size of the content.

func (*PutObject) String added in v1.0.0

func (o *PutObject) String() string

type S3 added in v1.0.0

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

S3 has S3 client and bucket list.

func New added in v1.0.0

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

New returns initialized *S3.

func NewFromSession added in v1.17.0

func NewFromSession(sess *session.Session) *S3

NewFromSession returns initialized *S3 from aws.Session.

func (*S3) CopyObject added in v1.14.1

func (svc *S3) CopyObject(req CopyObjectRequest) (CopyObjectResponse, error)

CopyObject executes `CopyObject` operation.

func (*S3) CreateBucket added in v1.0.0

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

CreateBucket creates new S3 bucket.

func (*S3) CreateBucketWithName added in v1.0.0

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

CreateBucketWithName creates new S3 bucket by given name.

func (*S3) Errorf added in v1.0.0

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

Errorf logging error information.

func (*S3) ForceDeleteBucket added in v1.0.0

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

ForceDeleteBucket deletes S3 bucket by given name.

func (*S3) GetBucket added in v1.0.0

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

GetBucket gets S3 bucket.

func (*S3) GetClient added in v1.17.1

func (svc *S3) GetClient() *SDK.S3

GetClient gets aws client.

func (*S3) Infof added in v1.0.0

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

Infof logging information.

func (*S3) IsExistBucket added in v1.0.0

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

IsExistBucket checks if the Bucket already exists or not.

func (*S3) SetEndpoint added in v1.17.1

func (svc *S3) SetEndpoint(endpoint string)

SetEndpoint sets endpoint.

func (*S3) SetLogger added in v1.0.0

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

SetLogger sets logger.

func (*S3) SetPrefix added in v1.17.1

func (svc *S3) SetPrefix(prefix string)

SetPrefix sets prefix.

Jump to

Keyboard shortcuts

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