storage

package
v0.0.0-...-c4985a1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSStore

type AWSStore struct {
	Session *session.Session
	// contains filtered or unexported fields
}

func NewAWSStore

func NewAWSStore(accessKeyID, secretAccessKey, region string) (*AWSStore, error)

func (*AWSStore) CopyObject

func (store *AWSStore) CopyObject(srcBucketName, srcObjectKey, destBucketName, destObjcetKey string) error

func (*AWSStore) CreateBucket

func (store *AWSStore) CreateBucket(bucketName string) error

func (*AWSStore) DeleteBucket

func (store *AWSStore) DeleteBucket(bucketName string) error

DeleteBucket 使用存储在结构体中的session删除一个指定的S3 Bucket。

func (*AWSStore) DeleteObject

func (store *AWSStore) DeleteObject(bucketName, objectKey string) error

func (*AWSStore) GetBucketAcl

func (store *AWSStore) GetBucketAcl(bucketName string) (*AccessControlPolicy, error)

func (*AWSStore) GetObject

func (store *AWSStore) GetObject(bucketName, objectKey string) (*Object, error)

func (*AWSStore) HeadObject

func (store *AWSStore) HeadObject(bucketName, objectKey string) (map[string]string, error)

func (*AWSStore) ListAllMyBuckets

func (store *AWSStore) ListAllMyBuckets() (*ListAllMyBucketsResult, error)

func (*AWSStore) ListBucket

func (store *AWSStore) ListBucket(bucketName string) (*ListBucketResult, error)

func (*AWSStore) MoveObject

func (store *AWSStore) MoveObject(srcBucketName, srcObjectKey, destBucketName, destObjcetKey string) error

func (*AWSStore) PutObject

func (store *AWSStore) PutObject(bucketName, objectKey string, data *Object) error

type AccessControlList

type AccessControlList struct {
	Grant []Grant `xml:"Grant"`
}

type AccessControlPolicy

type AccessControlPolicy struct {
	XMLName           xml.Name          `xml:"AccessControlPolicy"`
	Xmlns             string            `xml:"xmlns,attr"`
	Owner             Owner             `xml:"Owner"`
	AccessControlList AccessControlList `xml:"AccessControlList"`
}

AccessControlList 是 GET /BUCKETNAME?acl 的根 xml 元素

type Bucket

type Bucket struct {
	Name         string    `xml:"Name"`
	CreationDate time.Time `xml:"CreationDate"`
}

Bucket 与 Buckets.Bucket 相对应

type Buckets

type Buckets struct {
	Bucket []Bucket `xml:"Bucket"`
}

Buckets 与 ListAllMyBucketsResult.Buckets 相对应

type Content

type Content struct {
	Key          string    `xml:"Key"`
	LastModified time.Time `xml:"LastModified"`
	ETag         string    `xml:"ETag"`
	Size         int64     `xml:"Size"`
	StorageClass string    `xml:"StorageClass"`
	Owner        Owner     `xml:"Owner"`
}

Content 与 ListBucketResult.Contents 相对应

type Grant

type Grant struct {
	Grantee    Grantee `xml:"Grantee"`
	Permission string  `xml:"Permission"`
}

type Grantee

type Grantee struct {
	XMLName     xml.Name `xml:"Grantee"`
	XmlnsXsi    string   `xml:"xmlns:xsi,attr"`
	XsiType     string   `xml:"xsi:type,attr"`
	ID          string   `xml:"ID"`
	DisplayName string   `xml:"DisplayName"`
}

type Initiator

type Initiator struct {
	ID          string `xml:"ID"`
	DisplayName string `xml:"DisplayName"`
}

Initiator 与 ListPartsResult.Initiator 相对应

type LFSStore

type LFSStore struct {
	Bucket *blob.Bucket
	// contains filtered or unexported fields
}

Local File System (LFS) Store

func NewLFSStore

func NewLFSStore(basePath string) (*LFSStore, error)

func (*LFSStore) CopyObject

func (local *LFSStore) CopyObject(srcBucketName, srcObjectKey, destBucketName, destObjectKey string) error

func (*LFSStore) CreateBucket

func (local *LFSStore) CreateBucket(bucketName string) error

func (*LFSStore) DeleteBucket

func (local *LFSStore) DeleteBucket(bucketName string) error

func (*LFSStore) DeleteObject

func (local *LFSStore) DeleteObject(bucketName, objectKey string) error

func (*LFSStore) GetBucketAcl

func (local *LFSStore) GetBucketAcl(bucketName string) (*AccessControlPolicy, error)

func (*LFSStore) GetObject

func (local *LFSStore) GetObject(bucketName, objectKey string) (*Object, error)

func (*LFSStore) HeadObject

func (local *LFSStore) HeadObject(bucketName, objectKey string) (map[string]string, error)

func (*LFSStore) ListAllMyBuckets

func (local *LFSStore) ListAllMyBuckets() (*ListAllMyBucketsResult, error)

func (*LFSStore) ListBucket

func (local *LFSStore) ListBucket(bucketName string) (*ListBucketResult, error)

func (*LFSStore) MoveObject

func (local *LFSStore) MoveObject(srcBucketName, srcObjectKey, destBucketName, destObjectKey string) error

func (*LFSStore) PutObject

func (local *LFSStore) PutObject(bucketName, objectKey string, data *Object) error

type ListAllMyBucketsResult

type ListAllMyBucketsResult struct {
	XMLName xml.Name `xml:"ListAllMyBucketsResult"`
	Xmlns   string   `xml:"xmlns,attr"`
	Owner   Owner    `xml:"Owner"`
	Buckets Buckets  `xml:"Buckets"`
}

ListAllMyBucketsResult 是 GET / 的根 xml 元素

type ListBucketResult

type ListBucketResult struct {
	XMLName     xml.Name  `xml:"ListBucketResult"`
	Xmlns       string    `xml:"xmlns,attr"`
	Name        string    `xml:"Name"`
	Prefix      string    `xml:"Prefix"`
	MaxKeys     int       `xml:"MaxKeys"`
	Marker      string    `xml:"Marker"`
	IsTruncated bool      `xml:"IsTruncated"`
	Contents    []Content `xml:"Contents"`
}

ListBucketResult 是 GET /BUCKETNAME 的根 xml 元素

type ListPartsResult

type ListPartsResult struct {
	XMLName      xml.Name  `xml:"ListPartsResult"`
	Xmlns        string    `xml:"xmlns,attr"`
	Bucket       string    `xml:"Bucket"`
	Key          string    `xml:"Key"`
	UploadId     string    `xml:"UploadId"`
	Initiator    Initiator `xml:"Initiator"`
	Owner        Owner     `xml:"Owner"`
	StorageClass string    `xml:"StorageClass"`
	Part         Part      `xml:"Part"`
}

ListPartsResult 是 GET /BUCKETNAME/OBJECTNAME?uploadId=UPLOADID 的根 xml 元素

type Object

type Object struct {
	Key          string        // 对象的键(文件名)
	Size         int64         // 对象的大小,以字节为单位
	LastModified time.Time     // 对象最后被修改的时间
	ContentType  string        // 对象的MIME类型
	Data         io.ReadCloser // 对象的数据流
}

Object 表示S3中存储的一个对象,包括其元数据和数据内容。

type Owner

type Owner struct {
	ID          string `xml:"ID"`
	DisplayName string `xml:"DisplayName"`
}

Owner 与 ListAllMyBucketsResult.Owner 相对应

type Part

type Part struct {
	PartNumber   int       `xml:"PartNumber"`
	LastModified time.Time `xml:"LastModified"`
	ETag         string    `xml:"ETag"`
	Size         int       `xml:"Size"`
}

Part 与 ListPartsResult.Part 相对应

type StorageProvider

type StorageProvider interface {
	CreateBucket(bucketName string) error
	DeleteBucket(bucketName string) error
	ListBucket(bucketName string) (*ListBucketResult, error)
	ListAllMyBuckets() (*ListAllMyBucketsResult, error)
	GetBucketAcl(bucketName string) (*AccessControlPolicy, error)

	PutObject(bucketName, objectKey string, data *Object) error
	GetObject(bucketName, objectKey string) (*Object, error)
	DeleteObject(bucketName, objectKey string) error
	// ListObjects(bucketName string, prefix string, recursive bool) ([]*Object, error)
	CopyObject(srcBucketName, srcObjectKey, destBucketName, destObjectKey string) error
	MoveObject(srcBucketName, srcObjectKey, destBucketName, destObjectKey string) error
	HeadObject(bucketName, objectKey string) (map[string]string, error)
}

func NewStorageProvider

func NewStorageProvider(cfg config.Config) (StorageProvider, error)

Jump to

Keyboard shortcuts

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