backend

package
v0.0.0-...-e2627ae Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// CreatePresignedURLForUpload creates a presigned URL for uploading file to the bucket
	CreatePresignedURLForUpload(object BucketObject, expire time.Duration) (string, error)

	// CreatePresignedURLForDownload creates a presigned URL for downloading file from the bucket
	CreatePresignedURLForDownload(object BucketObject, expire time.Duration) (string, error)

	// DeleteObject delete an object in a bucket
	DeleteObject(object BucketObject) error

	// BatchDeleteObject delete an object in a bucket
	BatchDeleteObjects(objects []BucketObject) error

	// CopyObject copies one item from a bucket to another
	// sourceObject : source object (ex: mybucket and /folder/item)
	// destinationObject : destination object (ex: mybucket and /folder/item2)
	CopyObject(sourceObject BucketObject, destinationObject BucketObject) error
}

Backend provides an interface for S3

func NewS3Backend

func NewS3Backend(config ...S3BackendConfig) (Backend, error)

Create a new backend for s3 compatible backend

type BucketObject

type BucketObject struct {
	BucketName string
	Key        string
}

BucketObject is a tuple containing an object key (ex: /folder/item) and a bucket name (ex: mybucket)

func (BucketObject) FullPath

func (b BucketObject) FullPath() string

func (BucketObject) String

func (b BucketObject) String() string

type S3Backend

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

s3backend which will implement Backend interface

func (*S3Backend) BatchDeleteObjects

func (b *S3Backend) BatchDeleteObjects(objects []BucketObject) error

BatchDeleteObjects deletes a list of objects in batch mode

func (*S3Backend) CopyObject

func (b *S3Backend) CopyObject(sourceObject BucketObject, destinationObject BucketObject) error

Copy item from source to destination bucket

func (*S3Backend) CreatePresignedURLForDownload

func (b *S3Backend) CreatePresignedURLForDownload(object BucketObject, expire time.Duration) (string, error)

Create a presigned url for a download of an object

func (*S3Backend) CreatePresignedURLForUpload

func (b *S3Backend) CreatePresignedURLForUpload(object BucketObject, expire time.Duration) (string, error)

Create a presigned url for an upload of an object

func (*S3Backend) DeleteObject

func (b *S3Backend) DeleteObject(object BucketObject) error

Delete action for an object in a bucket

type S3BackendConfig

type S3BackendConfig struct {
	Host             string
	Region           string
	AccessKey        string
	SecretKey        string
	DisableSSL       bool
	S3ForcePathStyle bool
}

Config for s3backend for defining Host, Region, etc ...

Directories

Path Synopsis
Package backendtest provides utilities for backend testing
Package backendtest provides utilities for backend testing

Jump to

Keyboard shortcuts

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