s3

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	UploadToPublicBucket(ctx context.Context, body io.Reader, filename string) (*string, error)
	UploadToPrivateBucket(ctx context.Context, body io.Reader, filename string) (*string, error)
	DownloadFromPublicBucket(ctx context.Context, filename string) ([]byte, error)
	DownloadFromPrivateBucket(ctx context.Context, filename string) ([]byte, error)
	DeleteFileFromPublicBucket(ctx context.Context, filename string) error
	DeleteFileFromPrivateBucket(ctx context.Context, filename string) error
	FileExistsInPublicBucket(ctx context.Context, filename string) (bool, error)
	FileExistsInPrivateBucket(ctx context.Context, filename string) (bool, error)
	GetFileURLWithExpiry(ctx context.Context, filename string, duration time.Duration) (string, error)
	ListFilesInPrivateBucket(ctx context.Context, path string) ([]string, error)
}

func NewClient

func NewClient(config Configuration, obs observability.Observability) Client

type ClientImpl

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

func (*ClientImpl) DeleteFileFromPrivateBucket

func (i *ClientImpl) DeleteFileFromPrivateBucket(ctx context.Context, filename string) error

func (*ClientImpl) DeleteFileFromPublicBucket

func (i *ClientImpl) DeleteFileFromPublicBucket(ctx context.Context, filename string) error

func (*ClientImpl) DownloadFromPrivateBucket

func (i *ClientImpl) DownloadFromPrivateBucket(ctx context.Context, path string) ([]byte, error)

func (*ClientImpl) DownloadFromPublicBucket

func (i *ClientImpl) DownloadFromPublicBucket(ctx context.Context, path string) ([]byte, error)

func (*ClientImpl) FileExistsInPrivateBucket

func (i *ClientImpl) FileExistsInPrivateBucket(ctx context.Context, filename string) (bool, error)

func (*ClientImpl) FileExistsInPublicBucket

func (i *ClientImpl) FileExistsInPublicBucket(ctx context.Context, filename string) (bool, error)

func (*ClientImpl) GetFileURLWithExpiry

func (i *ClientImpl) GetFileURLWithExpiry(ctx context.Context, filename string, duration time.Duration) (string, error)

func (*ClientImpl) ListFilesInPrivateBucket

func (i *ClientImpl) ListFilesInPrivateBucket(ctx context.Context, path string) ([]string, error)

func (*ClientImpl) UploadToPrivateBucket

func (i *ClientImpl) UploadToPrivateBucket(ctx context.Context, body io.Reader, filename string) (*string, error)

todo add metadata to the upload, such as the user who uploaded it

func (*ClientImpl) UploadToPublicBucket

func (i *ClientImpl) UploadToPublicBucket(ctx context.Context, body io.Reader, filename string) (*string, error)

todo add metadata to the upload, such as the user who uploaded it

type Configuration

type Configuration struct {
	// Provider is the type of Configuration provider to use (AWS, Minio, etc).
	Provider string `yaml:"provider" json:"provider" mapstructure:"provider"`

	// Endpoint is the endpoint of the Configuration.
	Endpoint string `yaml:"endpoint" json:"endpoint" mapstructure:"endpoint"`

	// PublicURL is the public access url of the Configuration.
	PublicURL string `yaml:"publicUrl" json:"publicUrl" mapstructure:"publicUrl"`

	// AccessKey is access key for the Configuration connection.
	AccessKey string `yaml:"accessKey" json:"accessKey" mapstructure:"accessKey"`

	// Bucket is the name of the bucket to use.
	PrivateBucket string `yaml:"privateBucket" json:"privateBucket" mapstructure:"privateBucket"`

	// Bucket is the name of the bucket to use.
	PublicBucket string `yaml:"publicBucket" json:"publicBucket" mapstructure:"publicBucket"`

	// SecretKey is secret key for the Configuration connection.
	SecretKey string `yaml:"secretKey" json:"secretKey" mapstructure:"secretKey"`

	// Region is the region of the Configuration.
	Region string `yaml:"region" json:"region" mapstructure:"region"`

	AccessTokenId string `yaml:"accessTokenId" json:"accessTokenId" mapstructure:"accessTokenId"`

	// AccessTokenSecret is the access token secret for the Configuration connection.
	AccessTokenSecret string `yaml:"accessTokenSecret" json:"accessTokenSecret" mapstructure:"accessTokenSecret"`

	ForcePathStyle bool `yaml:"forcePathStyle" json:"forcePathStyle" mapstructure:"forcePathStyle"`

	// TLS is the TLS configuration for the Configuration connection.
	TLS tls.TLS `mapstructure:"tls" yaml:"tls" json:"tls"`
}

Configuration storage configuration with TLS

func (Configuration) ToAWSConfig

func (c Configuration) ToAWSConfig() *aws.Config

Jump to

Keyboard shortcuts

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