objectstorage

package
v2.1.64 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceNameS3 is name of s3 storage.
	ServiceNameS3 = "s3"

	// ServiceNameOSS is name of oss storage.
	ServiceNameOSS = "oss"

	// ServiceNameOBS is name of obs storage.
	ServiceNameOBS = "obs"
)
View Source
const (
	// DefaultTLSHandshakeTimeout is the default timeout of tls handshake of http client.
	DefaultTLSHandshakeTimeout = 30 * time.Second

	// DefaultResponseHeaderTimeout is the default timeout of response header of http client.
	DefaultResponseHeaderTimeout = 30 * time.Second

	// DefaultIdleConnTimeout is the default timeout of idle connection of http client.
	DefaultIdleConnTimeout = 5 * time.Minute

	// DefaultMaxIdleConnsPerHost is the default max idle connections per host of http client.
	DefaultMaxIdleConnsPerHost = 500

	// DefaultReadBufferSize is the default read buffer size of http client.
	DefaultReadBufferSize = 32 << 10

	// DefaultWriteBufferSize is the default write buffer size of http client.
	DefaultWriteBufferSize = 32 << 10

	// DefaultDisableCompression is the default disable compression of http client.
	DefaultDisableCompression = true

	// DefaultTimeout is the default timeout of http client.
	DefaultTimeout = time.Hour
)
View Source
const (
	// DefaultS3ForcePathStyle is the default force path style of s3.
	DefaultS3ForcePathStyle = true
)
View Source
const (
	// MetaDigest is key of digest meta.
	MetaDigest = "digest"
)
View Source
const (
	// OBSStorageClassStandardIA is the standard ia storage class of obs.
	OBSStorageClassStandardIA = "STANDARD_IA"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketMetadata

type BucketMetadata struct {
	// Name is bucket name.
	Name string

	// CreateAt is bucket create time.
	CreateAt time.Time
}

BucketMetadata provides metadata of bucket.

type Metadata added in v2.1.22

type Metadata struct {
	// Name is object storage name of type, it can be s3, oss or obs.
	Name string

	// Region is storage region.
	Region string

	// Endpoint is datacenter endpoint.
	Endpoint string
}

Metadata provides metadata of object storage.

type Method

type Method string

Method is the client operation method .

const (
	// MethodHead is the head operation.
	MethodHead Method = "HEAD"

	// MethodGet is the get operation.
	MethodGet Method = "GET"

	// MethodPut is the put operation.
	MethodPut Method = "PUT"

	// MethodPost is the post operation.
	MethodPost Method = "POST"

	// MethodDelete is the delete operation.
	MethodDelete Method = "Delete"

	// MethodList is the list operation.
	MethodList Method = "List"
)

type ObjectMetadata

type ObjectMetadata struct {
	// Key is object key.
	Key string

	// ContentDisposition is Content-Disposition header.
	ContentDisposition string

	// ContentEncoding is Content-Encoding header.
	ContentEncoding string

	// ContentLanguage is Content-Language header.
	ContentLanguage string

	// ContentLanguage is Content-Length header.
	ContentLength int64

	// ContentType is Content-Type header.
	ContentType string

	// ETag is ETag header.
	ETag string

	// Digest is object digest.
	Digest string

	// LastModifiedTime is last modified time.
	LastModifiedTime time.Time

	// StorageClass is object storage class.
	StorageClass string
}

ObjectMetadata provides metadata of object.

type ObjectMetadatas added in v2.0.30

type ObjectMetadatas struct {
	// CommonPrefixes are similar prefixes in object storage.
	CommonPrefixes []string `json:"CommonPrefixes"`

	// Metadatas are metadata of objects.
	Metadatas []*ObjectMetadata `json:"Metadatas"`
}

ObjectMetadatas provides metadatas of object.

type ObjectStorage

type ObjectStorage interface {
	// GetMetadata returns metadata of object storage.
	GetMetadata(ctx context.Context) *Metadata

	// GetBucketMetadata returns metadata of bucket.
	GetBucketMetadata(ctx context.Context, bucketName string) (*BucketMetadata, error)

	// CreateBucket creates bucket of object storage.
	CreateBucket(ctx context.Context, bucketName string) error

	// DeleteBucket deletes bucket of object storage.
	DeleteBucket(ctx context.Context, bucketName string) error

	// ListBucketMetadatas returns metadata of buckets.
	ListBucketMetadatas(ctx context.Context) ([]*BucketMetadata, error)

	// IsBucketExist returns whether the bucket exists.
	IsBucketExist(ctx context.Context, bucketName string) (bool, error)

	// GetObjectMetadata returns metadata of object.
	GetObjectMetadata(ctx context.Context, bucketName, objectKey string) (*ObjectMetadata, bool, error)

	// GetObjectMetadatas returns the metadata of the objects.
	GetObjectMetadatas(ctx context.Context, bucketName, prefix, marker, delimiter string, limit int64) (*ObjectMetadatas, error)

	// GetObject returns data of object.
	GetObject(ctx context.Context, bucketName, objectKey string) (io.ReadCloser, error)

	// PutObject puts data of object.
	PutObject(ctx context.Context, bucketName, objectKey, digest string, reader io.Reader) error

	// DeleteObject deletes data of object.
	DeleteObject(ctx context.Context, bucketName, objectKey string) error

	// IsObjectExist returns whether the object exists.
	IsObjectExist(ctx context.Context, bucketName, objectKey string) (bool, error)

	// CopyObject copy object from source to destination.
	CopyObject(ctx context.Context, bucketName, sourceObjectKey, destinationObjectKey string) error

	// GetSignURL returns sign url of object.
	GetSignURL(ctx context.Context, bucketName, objectKey string, method Method, expire time.Duration) (string, error)
}

ObjectStorage is the interface used for object storage.

func New

func New(name, region, endpoint, accessKey, secretKey string, options ...Option) (ObjectStorage, error)

New object storage interface.

type Option added in v2.0.9

type Option func(o *objectStorage)

Option is a functional option for configuring the objectStorage.

func WithHTTPClient added in v2.0.30

func WithHTTPClient(client *http.Client) Option

WithHTTPClient set the http client for objectStorage.

func WithS3ForcePathStyle added in v2.0.9

func WithS3ForcePathStyle(s3ForcePathStyle bool) Option

WithS3ForcePathStyle set the S3ForcePathStyle for objectStorage.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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