cos

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COSACLPrivate           = "private"
	COSACLPublicRead        = "public-read"
	COSACLPublicReadWrite   = "public-read-write"
	COSACLAuthenticatedRead = "authenticated-read"
)

Tencent COS canned ACL values, sent via the `x-cos-acl` header.

Variables

This section is empty.

Functions

func CollapseGrants added in v0.3.1

func CollapseGrants(out BucketACLResponse) string

CollapseGrants reduces the parsed ACL grant list back into a canned label.

func NormalizeCOSACL added in v0.3.1

func NormalizeCOSACL(level string) string

NormalizeCOSACL maps user-friendly aliases to canned COS ACL values.

func Sign added in v0.2.2

func Sign(req *http.Request, cred auth.Credential, now time.Time) error

Types

type APIError added in v0.2.2

type APIError struct {
	StatusCode int
	Method     string
	URL        string
	Code       string
	Message    string
	RequestID  string
	TraceID    string
}

func (*APIError) Error added in v0.2.2

func (e *APIError) Error() string

type BucketACLResponse added in v0.3.1

type BucketACLResponse struct {
	XMLName xml.Name `xml:"AccessControlPolicy"`
	Owner   struct {
		ID          string `xml:"ID"`
		DisplayName string `xml:"DisplayName"`
	} `xml:"Owner"`
	AccessControlList struct {
		Grant []struct {
			Grantee struct {
				Type string `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"`
				ID   string `xml:"ID"`
				URI  string `xml:"URI"`
			} `xml:"Grantee"`
			Permission string `xml:"Permission"`
		} `xml:"Grant"`
	} `xml:"AccessControlList"`
}

BucketACLResponse maps the body returned by `GET /?acl`. Tencent COS uses the same Owner+AccessControlList shape as S3; the canned-ACL view is reconstructed from grants because the GET path doesn't echo `x-cos-acl`.

type COSBucket added in v0.2.2

type COSBucket struct {
	Name         string `xml:"Name"`
	Region       string `xml:"Location"`
	CreationDate string `xml:"CreationDate"`
}

type COSObject added in v0.2.2

type COSObject struct {
	Key          string `xml:"Key"`
	Size         int64  `xml:"Size"`
	LastModified string `xml:"LastModified"`
	StorageClass string `xml:"StorageClass"`
}

type Client added in v0.2.2

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

func NewClient added in v0.2.2

func NewClient(cred auth.Credential, opts ...Option) *Client

func (*Client) GetBucketACL added in v0.3.1

func (c *Client) GetBucketACL(ctx context.Context, bucket, region string) (string, error)

GetBucketACL returns the canned ACL summary derived from the `?acl` grants.

func (*Client) ListBuckets added in v0.2.2

func (c *Client) ListBuckets(ctx context.Context) (*ListBucketsResponse, error)

func (*Client) ListObjects added in v0.2.2

func (c *Client) ListObjects(ctx context.Context, bucket, region, marker string, maxKeys int) (ListObjectsResponse, error)

func (*Client) PutBucketACL added in v0.3.1

func (c *Client) PutBucketACL(ctx context.Context, bucket, region, acl string) error

PutBucketACL sets the canned ACL on bucket via the `x-cos-acl` header.

type Driver added in v0.0.9

type Driver struct {
	Credential auth.Credential
	Client     *Client
	// contains filtered or unexported fields
}

func NewDriver added in v0.2.5

func NewDriver(cred auth.Credential, opts ...Option) *Driver

NewDriver creates a COS driver with optional client injections.

func (*Driver) AuditBucketACL added in v0.3.1

func (d *Driver) AuditBucketACL(ctx context.Context, bucket string) ([]schema.BucketACLEntry, error)

AuditBucketACL enumerates buckets and returns their canned ACL summary.

func (*Driver) ExposeBucket added in v0.3.1

func (d *Driver) ExposeBucket(ctx context.Context, bucket, level string) (string, error)

ExposeBucket sets the bucket public-readable (defaults to public-read).

func (*Driver) GetBuckets added in v0.0.9

func (d *Driver) GetBuckets(ctx context.Context) ([]schema.Storage, error)

func (*Driver) ListObjects added in v0.2.2

func (d *Driver) ListObjects(ctx context.Context, buckets map[string]string) ([]schema.BucketResult, error)

func (*Driver) SetClientOptions added in v0.2.5

func (d *Driver) SetClientOptions(opts ...Option)

SetClientOptions replaces the client options used by lazy client creation.

func (*Driver) TotalObjects added in v0.2.2

func (d *Driver) TotalObjects(ctx context.Context, buckets map[string]string) ([]schema.BucketResult, error)

func (*Driver) UnexposeBucket added in v0.3.1

func (d *Driver) UnexposeBucket(ctx context.Context, bucket string) error

UnexposeBucket reverts the bucket to private.

type HTTPStatusError added in v0.2.2

type HTTPStatusError struct {
	StatusCode int
	Status     string
	Body       string
}

func (*HTTPStatusError) Error added in v0.2.2

func (e *HTTPStatusError) Error() string

type ListBucketsResponse added in v0.2.2

type ListBucketsResponse struct {
	XMLName xml.Name    `xml:"ListAllMyBucketsResult"`
	Buckets []COSBucket `xml:"Buckets>Bucket"`
}

type ListObjectsResponse added in v0.2.2

type ListObjectsResponse struct {
	XMLName     xml.Name    `xml:"ListBucketResult"`
	Name        string      `xml:"Name"`
	Prefix      string      `xml:"Prefix"`
	Marker      string      `xml:"Marker"`
	NextMarker  string      `xml:"NextMarker"`
	MaxKeys     int         `xml:"MaxKeys"`
	IsTruncated bool        `xml:"IsTruncated"`
	Objects     []COSObject `xml:"Contents"`
}

type Option added in v0.2.2

type Option func(*Client)

func WithClock added in v0.2.2

func WithClock(now func() time.Time) Option

func WithHTTPClient added in v0.2.2

func WithHTTPClient(hc *http.Client) Option

func WithRetryPolicy added in v0.2.2

func WithRetryPolicy(p api.RetryPolicy) Option

func WithServiceEndpoint added in v0.2.2

func WithServiceEndpoint(rawURL string) Option

Jump to

Keyboard shortcuts

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