oss

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: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OSSACLPrivate         = "private"
	OSSACLPublicRead      = "public-read"
	OSSACLPublicReadWrite = "public-read-write"
)

Alibaba OSS canned ACL values. Levels accepted by the bucket-acl-check payload map onto these via NormalizeOSSACL.

Variables

This section is empty.

Functions

func NormalizeOSSACL added in v0.3.1

func NormalizeOSSACL(level string) string

NormalizeOSSACL maps user-friendly aliases to the canned OSS ACL values.

func Sign added in v0.2.2

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

Types

type APIError added in v0.2.2

type APIError struct {
	StatusCode int
	Code       string
	Message    string
	RequestID  string
	HostID     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 string `xml:"Grant"`
	} `xml:"AccessControlList"`
}

BucketACLResponse maps the body returned by `GET /?acl` on a bucket. The canned ACL value lives at AccessControlPolicy/AccessControlList/Grant and is one of "private", "public-read", or "public-read-write".

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 aliauth.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 grant ("private" / "public-read" / "public-read-write") currently set on bucket.

func (*Client) ListBuckets added in v0.2.2

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

func (*Client) ListObjectsV2 added in v0.2.2

func (c *Client) ListObjectsV2(ctx context.Context, bucket, region, continuationToken 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. acl must be one of the OSSACL* constants; the value is sent via the `x-oss-acl` header per OSS spec.

type Driver added in v0.0.9

type Driver struct {
	Cred   aliauth.Credential
	Region string
	Client *Client
	// contains filtered or unexported fields
}

func (*Driver) AuditBucketACL added in v0.3.1

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

AuditBucketACL enumerates buckets in scope and returns their canned ACL state. When bucket is empty all buckets are audited; otherwise the named bucket is audited if found.

func (*Driver) ExposeBucket added in v0.3.1

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

ExposeBucket sets bucket public-readable. level overrides the default `public-read` (e.g. `public-read-write`) if the caller wants a stronger expose.

func (*Driver) GetBuckets added in v0.0.9

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

func (*Driver) ListObjects added in v0.1.0

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

func (*Driver) NewClient added in v0.1.0

func (d *Driver) NewClient() (*Client, error)

func (*Driver) TotalObjects added in v0.1.0

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

Recommended:

./ossutil64 du oss://examplebucket/dir/ --block-size GB

Links:

https://help.aliyun.com/document_detail/129732.html
https://github.com/aliyun/ossutil

func (*Driver) UnexposeBucket added in v0.3.1

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

UnexposeBucket reverts bucket to `private`.

type ListBucketsResponse added in v0.2.2

type ListBucketsResponse struct {
	XMLName     xml.Name    `xml:"ListAllMyBucketsResult"`
	Prefix      string      `xml:"Prefix"`
	Marker      string      `xml:"Marker"`
	MaxKeys     int         `xml:"MaxKeys"`
	IsTruncated bool        `xml:"IsTruncated"`
	NextMarker  string      `xml:"NextMarker"`
	Buckets     []OSSBucket `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"`
	StartAfter            string      `xml:"StartAfter"`
	ContinuationToken     string      `xml:"ContinuationToken"`
	MaxKeys               int         `xml:"MaxKeys"`
	Delimiter             string      `xml:"Delimiter"`
	IsTruncated           bool        `xml:"IsTruncated"`
	NextContinuationToken string      `xml:"NextContinuationToken"`
	Objects               []OSSObject `xml:"Contents"`
}

type OSSBucket added in v0.2.2

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

type OSSObject added in v0.2.2

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

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(policy 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