cloudstorages

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGCSBucketEmpty    = errors.New("gcs bucket name is empty")
	ErrGCSProjectIDEmpty = errors.New("gcs project id is empty")
)

Sentinel errors (static) for validation (err113 compliant).

View Source
var (
	ErrS3BucketEmpty = errors.New("s3 bucket name is empty")
)

Sentinel errors for S3 validation.

Functions

This section is empty.

Types

type GCSConfig added in v1.10.1

type GCSConfig struct {
	ProjectID string
	Bucket    string
	Timeout   time.Duration // 0 means no timeout
}

GCSConfig defines configuration for GCSInstance (similar to S3Config for S3).

func LoadGCSConfigFromEnv added in v1.10.1

func LoadGCSConfigFromEnv() GCSConfig

LoadGCSConfigFromEnv builds config from environment variables.

type GCSInstance

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

func NewGCS

func NewGCS() *GCSInstance

NewGCS keeps backward compatibility (panic on failure) like previous version.

func NewGCSInstanceForTest added in v1.11.2

func NewGCSInstanceForTest(client *storage.Client, cfg GCSConfig) *GCSInstance

NewGCSInstanceForTest creates a GCSInstance with a custom client for testing purposes.

func NewGCSWithConfig added in v1.10.1

func NewGCSWithConfig(ctx context.Context, cfg GCSConfig) (*GCSInstance, error)

NewGCSWithConfig is new constructor returning error.

func (*GCSInstance) Delete

func (gcsinstance *GCSInstance) Delete(ctx context.Context, bucket string, key string) error

Delete deletes from storage.

func (*GCSInstance) Get

func (gcsinstance *GCSInstance) Get(ctx context.Context, bucket string, key string) (string, []byte, error)

Get gets from storage.

func (*GCSInstance) GetBucket added in v1.10.1

func (gcsinstance *GCSInstance) GetBucket() string

GetBucket returns configured bucket name.

func (*GCSInstance) GetByStreaming added in v1.5.0

func (gcsinstance *GCSInstance) GetByStreaming(ctx context.Context, bucket string, key string) (string, io.ReadCloser, error)

GetByStreaming gets from storage by streaming.

func (*GCSInstance) GetObjectInfo added in v1.6.0

func (gcsinstance *GCSInstance) GetObjectInfo(ctx context.Context, bucket string, key string) (entity.StorageObjectInfo, error)

GetObjectInfo gets from storage.

func (*GCSInstance) List added in v1.3.4

func (gcsinstance *GCSInstance) List(ctx context.Context, bucket string, key string) ([]string, error)

List get list from storage.

func (*GCSInstance) Put

func (gcsinstance *GCSInstance) Put(ctx context.Context, bucket string, path string, file io.ReadSeeker) error

Put puts to storage.

type S3Config added in v1.10.1

type S3Config struct {
	Region    string
	Endpoint  string
	UseLocal  bool
	AccessKey string
	SecretKey string
	Bucket    string
	Timeout   time.Duration // 0 means no timeout
}

S3Config defines configuration for S3Instance.

func LoadS3ConfigFromEnv added in v1.10.1

func LoadS3ConfigFromEnv() S3Config

LoadS3ConfigFromEnv builds config from environment variables (backward compatibility helper).

type S3Instance

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

S3Instance struct.

func NewS3

func NewS3() *S3Instance

NewS3 keeps backward compatible panic behavior.

func NewS3WithConfig added in v1.10.1

func NewS3WithConfig(ctx context.Context, cfgIn S3Config) (*S3Instance, error)

NewS3WithConfig is the new constructor returning error.

func (*S3Instance) Delete

func (s3instance *S3Instance) Delete(ctx context.Context, bucket, key string) error

Delete deletes from storage.

func (*S3Instance) Get

func (s3instance *S3Instance) Get(ctx context.Context, bucket, key string) (string, []byte, error)

Get gets from storage and returns bytes.

func (*S3Instance) GetBucket added in v1.10.1

func (s3instance *S3Instance) GetBucket() string

GetBucket returns configured bucket name.

func (*S3Instance) GetByStreaming added in v1.5.0

func (s3instance *S3Instance) GetByStreaming(ctx context.Context, bucket, key string) (string, io.ReadCloser, error)

GetByStreaming gets from storage by streaming (no timeout).

func (*S3Instance) GetObjectInfo added in v1.6.0

func (s3instance *S3Instance) GetObjectInfo(ctx context.Context, bucket, key string) (entity.StorageObjectInfo, error)

GetObjectInfo gets object head metadata.

func (*S3Instance) List added in v1.3.4

func (s3instance *S3Instance) List(ctx context.Context, bucket, key string) ([]string, error)

List get list from storage.

func (*S3Instance) Put

func (s3instance *S3Instance) Put(ctx context.Context, bucket, path string, file io.ReadSeeker) error

Put puts to storage.

type StorageInstance

type StorageInstance interface {
	Put(ctx context.Context, bucket string, path string, file io.ReadSeeker) error
	Get(ctx context.Context, bucket string, key string) (string, []byte, error)
	GetByStreaming(ctx context.Context, bucket string, key string) (string, io.ReadCloser, error)
	GetObjectInfo(ctx context.Context, bucket string, key string) (entity.StorageObjectInfo, error)
	List(ctx context.Context, bucket string, key string) ([]string, error)
	Delete(ctx context.Context, bucket string, key string) error
	GetBucket() string
}

StorageInstance interface.

Jump to

Keyboard shortcuts

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