storage

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompleteMultipartUpload

func CompleteMultipartUpload(key string) error

func CompleteUploadMultipartMod

func CompleteUploadMultipartMod(ctx context.Context, modID string, name string, versionID string) (bool, string)

func CopyObjectFromOldBucket

func CopyObjectFromOldBucket(key string) error

func CopyObjectToOldBucket

func CopyObjectToOldBucket(key string) error

func DeleteMod

func DeleteMod(ctx context.Context, modID string, name string, versionID string) bool

func EncodeName

func EncodeName(name string) string
func GenerateDownloadLink(key string) string

func Get

func Get(key string) (io.ReadCloser, error)

func GetMod

func GetMod(modID string, name string, versionID string) (io.ReadCloser, error)

func InitializeStorage

func InitializeStorage(ctx context.Context)

func RenameVersion

func RenameVersion(ctx context.Context, modID string, name string, versionID string, version string) (bool, string)

func ScheduleCopyAllObjectsFromOldBucket

func ScheduleCopyAllObjectsFromOldBucket(scheduler func(string))

func StartMultipartUpload

func StartMultipartUpload(key string) error

func StartUploadMultipartMod

func StartUploadMultipartMod(ctx context.Context, modID string, name string, versionID string) (bool, string)
func UploadModLogo(ctx context.Context, modID string, data io.ReadSeeker) (bool, string)

func UploadMultipartMod

func UploadMultipartMod(ctx context.Context, modID string, name string, versionID string, part int64, data io.ReadSeeker) (bool, string)

func UploadPart

func UploadPart(key string, part int64, data io.ReadSeeker) error

func UploadUserAvatar

func UploadUserAvatar(ctx context.Context, userID string, data io.ReadSeeker) (bool, string)

Types

type B2

type B2 struct {
	BaseURL   string
	S3Client  *s3.S3
	S3Session *session.Session
	Config    Config
}

func (*B2) CompleteMultipartUpload

func (b2o *B2) CompleteMultipartUpload(key string) error

func (*B2) Delete

func (b2o *B2) Delete(key string) error

func (*B2) Get

func (b2o *B2) Get(key string) (io.ReadCloser, error)

func (*B2) Meta

func (b2o *B2) Meta(key string) (*ObjectMeta, error)

func (*B2) Put

func (b2o *B2) Put(ctx context.Context, key string, body io.ReadSeeker) (string, error)

func (*B2) Rename

func (b2o *B2) Rename(from string, to string) error

func (*B2) SignGet

func (b2o *B2) SignGet(key string) (string, error)

func (*B2) SignPut

func (b2o *B2) SignPut(key string) (string, error)

func (*B2) StartMultipartUpload

func (b2o *B2) StartMultipartUpload(key string) error

func (*B2) UploadPart

func (b2o *B2) UploadPart(key string, part int64, data io.ReadSeeker) error

type Config

type Config struct {
	Type     string `json:"type"`
	Bucket   string `json:"bucket"`
	Key      string `json:"key"`
	Secret   string `json:"secret"`
	BaseURL  string `json:"base_url"`
	Endpoint string `json:"endpoint"`
	Region   string `json:"region"`
}

type ObjectMeta

type ObjectMeta struct {
	ContentLength *int64
	ContentType   *string
}

func ModVersionMeta

func ModVersionMeta(ctx context.Context, modID string, name string, versionID string) *ObjectMeta

type S3

type S3 struct {
	BaseURL   string
	S3Client  *s3.S3
	S3Session *session.Session
	Config    Config
}

func (*S3) CompleteMultipartUpload

func (s3o *S3) CompleteMultipartUpload(key string) error

func (*S3) Delete

func (s3o *S3) Delete(key string) error

func (*S3) Get

func (s3o *S3) Get(key string) (io.ReadCloser, error)

func (*S3) Meta

func (s3o *S3) Meta(key string) (*ObjectMeta, error)

func (*S3) Put

func (s3o *S3) Put(ctx context.Context, key string, body io.ReadSeeker) (string, error)

func (*S3) Rename

func (s3o *S3) Rename(from string, to string) error

func (*S3) SignGet

func (s3o *S3) SignGet(key string) (string, error)

func (*S3) SignPut

func (s3o *S3) SignPut(key string) (string, error)

func (*S3) StartMultipartUpload

func (s3o *S3) StartMultipartUpload(key string) error

func (*S3) UploadPart

func (s3o *S3) UploadPart(key string, part int64, data io.ReadSeeker) error

type Storage

type Storage interface {
	Get(key string) (io.ReadCloser, error)
	Put(ctx context.Context, key string, body io.ReadSeeker) (string, error)
	SignGet(key string) (string, error)
	SignPut(key string) (string, error)
	StartMultipartUpload(key string) error
	UploadPart(key string, part int64, data io.ReadSeeker) error
	CompleteMultipartUpload(key string) error
	Rename(from string, to string) error
	Delete(key string) error
	Meta(key string) (*ObjectMeta, error)
}

type Wasabi

type Wasabi struct {
	S3Client *s3.S3
	Bucket   *string
}

func (*Wasabi) CompleteMultipartUpload

func (wasabi *Wasabi) CompleteMultipartUpload(key string) error

func (*Wasabi) Delete

func (wasabi *Wasabi) Delete(key string) error

func (*Wasabi) Get

func (wasabi *Wasabi) Get(key string) (io.ReadCloser, error)

func (*Wasabi) Meta

func (wasabi *Wasabi) Meta(key string) (*ObjectMeta, error)

func (*Wasabi) Put

func (wasabi *Wasabi) Put(ctx context.Context, key string, body io.ReadSeeker) (string, error)

func (*Wasabi) Rename

func (wasabi *Wasabi) Rename(from string, to string) error

func (*Wasabi) SignGet

func (wasabi *Wasabi) SignGet(key string) (string, error)

func (*Wasabi) SignPut

func (wasabi *Wasabi) SignPut(key string) (string, error)

func (*Wasabi) StartMultipartUpload

func (wasabi *Wasabi) StartMultipartUpload(key string) error

func (*Wasabi) UploadPart

func (wasabi *Wasabi) UploadPart(key string, part int64, data io.ReadSeeker) error

Jump to

Keyboard shortcuts

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