Documentation
¶
Index ¶
- Constants
- func NewService(ctx gousu.IContext) gousu.IService
- type FakeWriterAt
- type IService
- type ProgressCallback
- type ProgressWriter
- type Service
- func (s *Service) AddBucket(profile *model.ProfileV1, bucket *model.BucketV1) error
- func (s *Service) AddObject(profile *model.ProfileV1, bucketName string, filename string, ...) error
- func (s *Service) DeleteBucket(profile *model.ProfileV1, bucketName string) error
- func (s *Service) DeleteObject(profile *model.ProfileV1, bucketName string, objectKey string) error
- func (s *Service) DownloadObject(profile *model.ProfileV1, bucket string, objectKey string, out io.Writer) error
- func (s *Service) DownloadObjectToFile(profile *model.ProfileV1, bucketName string, objectKey string, filename string, ...) error
- func (s *Service) GetBucketStats(profile *model.ProfileV1, bucket string, force bool) (*model.BucketStatsV1, error)
- func (s *Service) GetBuckets(profile *model.ProfileV1) ([]*model.BucketV1, error)
- func (s *Service) GetObject(profile *model.ProfileV1, bucketName string, objectKey string) (*model.ObjectV1, error)
- func (s *Service) GetObjects(profile *model.ProfileV1, bucket string, continuationToken null.String, ...) ([]*model.ObjectV1, string, error)
- func (s *Service) Health() error
- func (s *Service) Name() string
- func (s *Service) Start() error
- func (s *Service) Stop() error
Constants ¶
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!
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 ¶
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
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the service used to access the s3 storage server
func (*Service) AddBucket ¶
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 ¶
DeleteBucket deletes as an empty bucket
func (*Service) DeleteObject ¶
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 (*Service) GetBuckets ¶
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