objectstorage

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 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 (
	// DefaultGetObjectMetadatasLimit is the default limit of get object metadatas.
	DefaultGetObjectMetadatasLimit = 1000
)
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 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 v1.0.11

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

	Metadatas []*ObjectMetadata `json:"Metadatas"`
}

type ObjectStorage

type ObjectStorage interface {
	// 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)

	// GetOject returns data of object.
	GetOject(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

type Option func(o *objectStorage)

Option is a functional option for configuring the objectStorage.

func WithS3ForcePathStyle

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