s3

package
v0.0.0-...-f6b2f6e Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBufferSize = 10 * mib
	DefaultExpire     = 15 * time.Minute
)
View Source
const (
	ExpireMaxLimit = 7 * 24 * time.Hour
	ExpireMinLimit = 1 * time.Minute

	MultipartMaxParts = 10000
	MultipartMinSize  = 5 * mib
)

Variables

View Source
var ErrClientEmpty = stderr.New("s3: storage client credentials not configured")

Functions

func New

func New(ctx context.Context, opts ...*Options) (storage.ObjectStorage, error)

func NewEmpty

func NewEmpty(ctx context.Context, opts ...*Options) (storage.ObjectStorage, error)

NewEmpty initializes a new s3 client that does not implicitly load credentials from the environment. Credentials must be set using the StorageSettings provided with the Context.

func NewSigner

func NewSigner(
	unsignedHeaders []string,
	optFns ...func(signer *v4.SignerOptions),
) v4.HTTPSigner

Types

type Options

type Options struct {

	// ContentType of the uploaded objects
	ContentType *string
	// FilenameSuffix adds the suffix to the content-disposition for object downloads
	FilenameSuffix *string
	// DefaultExpire is the fallback presign expire duration
	// (defaults to 15min).
	DefaultExpire *time.Duration
	// BufferSize sets the buffer size allocated for uploads.
	// This implicitly sets the upper limit for upload size:
	// BufferSize * 10000 (defaults to: 5MiB).
	BufferSize *int

	// UnsignedHeaders forces the driver to skip the named headers from the
	// being signed.
	UnsignedHeaders []string

	// Transport sets an alternative RoundTripper used by the Go HTTP
	// client.
	Transport http.RoundTripper
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions(opts ...*Options) *Options

func (*Options) SetBucketName

func (opts *Options) SetBucketName(bucketName string) *Options

func (*Options) SetBufferSize

func (opts *Options) SetBufferSize(bufferSize int) *Options

func (*Options) SetContentType

func (opts *Options) SetContentType(contentType string) *Options

func (*Options) SetDefaultExpire

func (opts *Options) SetDefaultExpire(defaultExpire time.Duration) *Options

func (*Options) SetExternalURI

func (opts *Options) SetExternalURI(externalURI string) *Options

func (*Options) SetFilenameSuffix

func (opts *Options) SetFilenameSuffix(suffix string) *Options

func (*Options) SetForcePathStyle

func (opts *Options) SetForcePathStyle(forcePathStyle bool) *Options

func (*Options) SetProxyURI

func (opts *Options) SetProxyURI(proxyURI *url.URL) *Options

func (*Options) SetRegion

func (opts *Options) SetRegion(region string) *Options

func (*Options) SetStaticCredentials

func (opts *Options) SetStaticCredentials(key, secret, sessionToken string) *Options

func (*Options) SetTransport

func (opts *Options) SetTransport(transport http.RoundTripper) *Options

func (*Options) SetURI

func (opts *Options) SetURI(URI string) *Options

func (*Options) SetUnsignedHeaders

func (opts *Options) SetUnsignedHeaders(unsignedHeaders []string) *Options

func (*Options) SetUseAccelerate

func (opts *Options) SetUseAccelerate(useAccelerate bool) *Options

func (Options) Validate

func (opts Options) Validate() error

type Signer

type Signer struct {
	v4.Signer
	// Google Cloud Storage does not tolerate signing the Accept-Encoding header
	UnsignedHeaders []string
}

func (Signer) SignHTTP

func (s Signer) SignHTTP(
	ctx context.Context,
	credentials aws.Credentials,
	r *http.Request,
	payloadHash, service, region string,
	signingTime time.Time,
	optFns ...func(*v4.SignerOptions)) error

type SimpleStorageService

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

SimpleStorageService - AWS S3 client. Data layer for file storage. Implements model.FileStorage interface

func (*SimpleStorageService) DeleteObject

func (s *SimpleStorageService) DeleteObject(ctx context.Context, path string) error

Delete removes deleted file from storage. Noop if ID does not exist.

func (*SimpleStorageService) DeleteRequest

func (s *SimpleStorageService) DeleteRequest(
	ctx context.Context,
	path string,
	expireAfter time.Duration,
) (*model.Link, error)

DeleteRequest returns a presigned deletion request

func (*SimpleStorageService) GetObject

func (s *SimpleStorageService) GetObject(
	ctx context.Context,
	path string,
) (io.ReadCloser, error)

func (*SimpleStorageService) GetRequest

func (s *SimpleStorageService) GetRequest(
	ctx context.Context,
	objectPath string,
	filename string,
	expireAfter time.Duration,
) (*model.Link, error)

GetRequest duration is limited to 7 days (AWS limitation)

func (*SimpleStorageService) HealthCheck

func (s *SimpleStorageService) HealthCheck(ctx context.Context) error

func (*SimpleStorageService) PutObject

func (s *SimpleStorageService) PutObject(
	ctx context.Context,
	path string,
	src io.Reader,
) error

UploadArtifact uploads given artifact into the file server (AWS S3 or minio) using objectID as a key. If the artifact is larger than 5 MiB, the file is uploaded using the s3 multipart API, otherwise the object is created in a single request.

func (*SimpleStorageService) PutRequest

func (s *SimpleStorageService) PutRequest(
	ctx context.Context,
	path string,
	expireAfter time.Duration,
) (*model.Link, error)

func (*SimpleStorageService) StatObject

func (s *SimpleStorageService) StatObject(
	ctx context.Context,
	path string,
) (*storage.ObjectInfo, error)

Exists check if selected object exists in the storage

type StaticCredentials

type StaticCredentials struct {
	Key    string `json:"key"`
	Secret string `json:"secret"`
	Token  string `json:"token"`
}

func (StaticCredentials) Retrieve

func (StaticCredentials) Validate

func (creds StaticCredentials) Validate() error

Jump to

Keyboard shortcuts

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