s3

package
v0.0.0-...-92b1827 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "s3"

ServiceName defines the name of the s3 service

Variables

This section is empty.

Functions

func NewService

func NewService(ctx gousu.IContext) gousu.IService

NewService creates a new instance of s3 service

Types

type FakeWriterAt

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

FakeWriterAt can be used to pipe an WriterAt to an regular Writer

Important: It must be made sure the WriterAt is always called without "jumping" "At"s!

func (FakeWriterAt) WriteAt

func (fw FakeWriterAt) WriteAt(p []byte, offset int64) (n int, err error)

WriteAt writes to the writer and ignores the offset

type IService

type IService interface {
	gousu.IService

	GetBuckets(profile *model.ProfileV1) ([]*model.BucketV1, error)
	AddBucket(profile *model.ProfileV1, bucket *model.BucketV1) error
	DeleteBucket(profile *model.ProfileV1, bucketName string) error
	GetBucketStats(profile *model.ProfileV1, bucket string, force bool) (*model.BucketStatsV1, error)

	GetObjects(profile *model.ProfileV1, bucket string, continuationToken null.String, size int64) ([]*model.ObjectV1, string, error)
	GetObject(profile *model.ProfileV1, bucket string, objectKey string) (*model.ObjectV1, error)
	DownloadObject(profile *model.ProfileV1, bucket string, objectKey string, out io.Writer) error
	DownloadObjectToFile(profile *model.ProfileV1, bucket string, objectKey string, filename string, progressClb ProgressCallback) error
	AddObject(profile *model.ProfileV1, bucketName string, filename string, file multipart.File) error
	DeleteObject(profile *model.ProfileV1, bucketName string, objectKey string) error
}

IService defines the interface of s3 service

type ProgressCallback

type ProgressCallback func(written int64, total int64)

ProgressCallback defines a function that is called on progress

type ProgressWriter

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

ProgressWriter is a WriterAt that can be used to track the progress of the underlying WriterAt by calling a ProgressCallback function

func NewProgressWriter

func NewProgressWriter(writer io.WriterAt, total int64, progressClb ProgressCallback) *ProgressWriter

NewProgressWriter constructs a new ProgressWriter for an unerlying WriterAt with a total expected size of data being written and a ProgressCallback

func (*ProgressWriter) WriteAt

func (p *ProgressWriter) WriteAt(buf []byte, off int64) (int, error)

WriteAt writes data to the underlying WriterAt, calling the ProgressCallback in a separate go "thread" asynchronously

type Service

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

Service is the service used to access the s3 storage server

func (*Service) AddBucket

func (s *Service) AddBucket(profile *model.ProfileV1, bucket *model.BucketV1) error

AddBucket creates a new bucket on the S3 storage server sepcified by the passed profile

Returns nil if the Bucket was created and error if not

func (*Service) AddObject

func (s *Service) AddObject(profile *model.ProfileV1, bucketName string, filename string, file multipart.File) error

AddObject uploads an object to the bucket in the S3 storage specified by the passed profile. If an object with this key already exists in this bucket it is replaced by the new file

Returns nil on success or else error

func (*Service) DeleteBucket

func (s *Service) DeleteBucket(profile *model.ProfileV1, bucketName string) error

DeleteBucket deletes as an empty bucket

func (*Service) DeleteObject

func (s *Service) DeleteObject(profile *model.ProfileV1, bucketName string, objectKey string) error

DeleteObject deletes an Object

func (*Service) DownloadObject

func (s *Service) DownloadObject(profile *model.ProfileV1, bucket string, objectKey string, out io.Writer) error

DownloadObject downloads an object to an writer

Returns nil on success after the download has finished, else error

func (*Service) DownloadObjectToFile

func (s *Service) DownloadObjectToFile(profile *model.ProfileV1, bucketName string, objectKey string, filename string, progressClb ProgressCallback) error

DownloadObjectToFile downloads an Object to a file, tracking the download progress via a ProgressCallback

func (*Service) GetBucketStats

func (s *Service) GetBucketStats(profile *model.ProfileV1, bucket string, force bool) (*model.BucketStatsV1, error)

func (*Service) GetBuckets

func (s *Service) GetBuckets(profile *model.ProfileV1) ([]*model.BucketV1, error)

GetBuckets lists the buckets in the S3 Storage specified by the passed profile. If the profile contains pre-defined buckets, these are returned instead and ListBuckets is not called (this can be usefull if the profile's user doesn't have the ListBucket-permission)

func (*Service) GetObject

func (s *Service) GetObject(profile *model.ProfileV1, bucketName string, objectKey string) (*model.ObjectV1, error)

GetObject loads the objects details

Important: Does not load the owner!

func (*Service) GetObjects

func (s *Service) GetObjects(profile *model.ProfileV1, bucket string, continuationToken null.String, size int64) ([]*model.ObjectV1, string, error)

GetObjects loads a list of max. 1000 objects from the given bucket

func (*Service) Health

func (s *Service) Health() error

Health returns always 'ok' (nil)

func (*Service) Name

func (s *Service) Name() string

Name returns the service's name defined by ServiceName

func (*Service) Start

func (s *Service) Start() error

Start does nothing

func (*Service) Stop

func (s *Service) Stop() error

Stop does nothing

Jump to

Keyboard shortcuts

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