Documentation
¶
Index ¶
- Variables
- type GCSConfig
- type GCSInstance
- func (gcsinstance *GCSInstance) Delete(ctx context.Context, bucket string, key string) error
- func (gcsinstance *GCSInstance) Get(ctx context.Context, bucket string, key string) (string, []byte, error)
- func (gcsinstance *GCSInstance) GetBucket() string
- func (gcsinstance *GCSInstance) GetByStreaming(ctx context.Context, bucket string, key string) (string, io.ReadCloser, error)
- func (gcsinstance *GCSInstance) GetObjectInfo(ctx context.Context, bucket string, key string) (entity.StorageObjectInfo, error)
- func (gcsinstance *GCSInstance) List(ctx context.Context, bucket string, key string) ([]string, error)
- func (gcsinstance *GCSInstance) Put(ctx context.Context, bucket string, path string, file io.ReadSeeker) error
- type S3Config
- type S3Instance
- func (s3instance *S3Instance) Delete(ctx context.Context, bucket, key string) error
- func (s3instance *S3Instance) Get(ctx context.Context, bucket, key string) (string, []byte, error)
- func (s3instance *S3Instance) GetBucket() string
- func (s3instance *S3Instance) GetByStreaming(ctx context.Context, bucket, key string) (string, io.ReadCloser, error)
- func (s3instance *S3Instance) GetObjectInfo(ctx context.Context, bucket, key string) (entity.StorageObjectInfo, error)
- func (s3instance *S3Instance) List(ctx context.Context, bucket, key string) ([]string, error)
- func (s3instance *S3Instance) Put(ctx context.Context, bucket, path string, file io.ReadSeeker) error
- type StorageInstance
Constants ¶
This section is empty.
Variables ¶
var ( ErrGCSBucketEmpty = errors.New("gcs bucket name is empty") ErrGCSProjectIDEmpty = errors.New("gcs project id is empty") )
Sentinel errors (static) for validation (err113 compliant).
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
}
GCSInstance struct. 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 NewGCSWithConfig ¶ added in v1.10.1
func NewGCSWithConfig(ctx context.Context, cfg GCSConfig) (*GCSInstance, error)
NewGCS creates a new GCSInstance. NewGCSWithConfig is new constructor returning error.
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 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) 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) 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.