ufile

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 (
	UFileTypePrivate = "private"
	UFileTypePublic  = "public"
	UFileTypeLimited = "limited"
)

UCloud UFile bucket access types (the canned-ACL-equivalent UFile concept). `private` and `public` are the two stable values; `limited` is "限制公开读" (trigger-style access via referer/ip rules) and is mapped through but not a default expose target because behavior depends on per-bucket trigger rules.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	Credential ucloudauth.Credential
	Client     *api.Client
	FileClient *FileClient
	ProjectID  string
	Region     string
}

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 the canned access type for each. UCloud reports the Type via the same DescribeBucket action used by cloudlist, so the audit path is a single JSON-RPC roundtrip per page.

func (*Driver) ExposeBucket added in v0.3.1

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

ExposeBucket flips bucket to `public` (or the supplied level if it is a recognised UFile type). UCloud `UpdateBucket` only takes BucketName + Type.

func (*Driver) GetBuckets

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

func (*Driver) ListObjects added in v0.3.1

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

ListObjects fans out across the resolved bucket→region map and returns one schema.BucketResult per bucket containing the page of objects discovered. Mirrors the alibaba/aws/tencent BucketDump shape.

func (*Driver) ResolveBucketRegion added in v0.3.1

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

ResolveBucketRegion looks up the region for a single bucket via DescribeBucket. Used by ucloud.Provider.bucketInfos when the caller passes a specific bucket.

func (*Driver) TotalObjects added in v0.3.1

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

TotalObjects pages through every bucket and returns the aggregate object count + total size. The summary view is what the bucket-check `total` action surfaces in the REPL table.

func (*Driver) UnexposeBucket added in v0.3.1

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

UnexposeBucket reverts bucket to `private`.

type FileClient added in v0.3.1

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

FileClient is the UFile bucket-level client. Distinct from the JSON-RPC `api.Client` (`api.ucloud.cn`) which only handles bucket creation / listing — object-level operations live on the per-bucket `*.ufileos.com` host with HMAC-SHA1 signing per UFile's own auth scheme.

func NewFileClient added in v0.3.1

func NewFileClient(cred ucloudauth.Credential, opts ...FileClientOption) *FileClient

func (*FileClient) PrefixFileList added in v0.3.1

func (c *FileClient) PrefixFileList(ctx context.Context, bucket, region, prefix, marker string, limit int) (PrefixFileListResponse, error)

PrefixFileList enumerates objects in bucket prefixed by prefix. region is the bucket region (e.g. "cn-bj"). marker is the continuation cursor returned by the previous call; pass "" for the first page.

type FileClientOption added in v0.3.1

type FileClientOption func(*FileClient)

func WithFileClock added in v0.3.1

func WithFileClock(now func() time.Time) FileClientOption

func WithFileEndpointFormat added in v0.3.1

func WithFileEndpointFormat(template string) FileClientOption

WithFileEndpointFormat overrides the per-bucket endpoint template. The format string takes two `%s` placeholders: bucket and region. Used by tests to redirect the per-bucket host onto a single httptest server.

func WithFileHTTPClient added in v0.3.1

func WithFileHTTPClient(hc *http.Client) FileClientOption

func WithFileRetryPolicy added in v0.3.1

func WithFileRetryPolicy(p ucloudapi.RetryPolicy) FileClientOption

type PrefixFileListResponse added in v0.3.1

type PrefixFileListResponse struct {
	BucketName string        `json:"BucketName" xml:"-"`
	BucketID   string        `json:"BucketId" xml:"-"`
	NextMarker string        `json:"NextMarker" xml:"-"`
	DataSet    []UFileObject `json:"DataSet" xml:"-"`
}

PrefixFileListResponse mirrors the body returned by `GET /?list`.

type UFileObject added in v0.3.1

type UFileObject struct {
	FileName     string `json:"FileName"`
	Hash         string `json:"Hash"`
	MimeType     string `json:"MimeType"`
	Size         int64  `json:"Size"`
	ModifyTime   int64  `json:"ModifyTime"`
	StorageClass string `json:"StorageClass"`
}

Jump to

Keyboard shortcuts

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