ctfile

package
v4.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addition

type Addition struct {
	// Session is the OpenAPI token generated in the CtFile backend under
	// 「开放接口登录密钥管理」. Required.
	Session string `json:"session" required:"true" secret:"true" help:"OpenAPI session token from 开放接口登录密钥管理"`

	// CloudType selects namespace: "public" (default) or "private".
	CloudType string `json:"cloud_type" type:"select" options:"public,private" default:"public"`

	// BaseURL is the API root, defaulting to https://rest.ctfile.com/v1.
	BaseURL string `json:"base_url" default:"https://rest.ctfile.com/v1" help:"API base URL"`

	// OrderBy controls server-side sort field.
	OrderBy string `json:"order_by" type:"select" options:"name,size,time" default:"name"`

	// OrderDirection is the sort direction.
	OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`

	// UserAgent overrides the default Chrome-like UA sent with every request.
	UserAgent string `` /* 139-byte string literal not displayed */

	driver.RootID
}

Addition holds all user-configurable fields for the CtFile driver.

type CtFile

type CtFile struct {
	model.Storage
	Addition
}

CtFile implements driver.Driver for 城通网盘 (CtFile) via the OpenAPI session-based authentication. No email/password/SMS login is used.

func (*CtFile) Config

func (d *CtFile) Config() driver.Config

func (*CtFile) Copy

func (d *CtFile) Copy(ctx context.Context, srcObj, dstDir model.Obj) error

Copy copies srcObj into dstDir. The spec explicitly requires implementation; the Worker's "unimplemented" note is overridden here. The API endpoint is POST /{ns}/file/copy.

func (*CtFile) Drop

func (d *CtFile) Drop(ctx context.Context) error

func (*CtFile) GetAddition

func (d *CtFile) GetAddition() driver.Additional

func (*CtFile) Init

func (d *CtFile) Init(ctx context.Context) error
func (d *CtFile) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*model.Link, error)

Link fetches the CDN download URL for file via fetch_url.

func (*CtFile) List

func (d *CtFile) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error)

List returns the contents of dir (both sub-folders and files).

func (*CtFile) MakeDir

func (d *CtFile) MakeDir(ctx context.Context, parentDir model.Obj, dirName string) (model.Obj, error)

MakeDir creates a sub-folder under parentDir.

func (*CtFile) Move

func (d *CtFile) Move(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error)

Move relocates srcObj into dstDir.

func (*CtFile) Put

func (d *CtFile) Put(ctx context.Context, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress) error

Put uploads a file to dstDir. The stream is cached so the checksum and the subsequent multipart upload can reuse it without keeping the entire file in memory.

func (*CtFile) Remove

func (d *CtFile) Remove(ctx context.Context, obj model.Obj) error

Remove deletes obj (moves to trash).

func (*CtFile) Rename

func (d *CtFile) Rename(ctx context.Context, srcObj model.Obj, newName string) (model.Obj, error)

Rename changes the name of srcObj to newName.

type Resp

type Resp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Resp is the unified response wrapper. Business fields are decoded via utils.Json to stay tolerant of the server's loosely-typed payloads (numbers may arrive as strings and vice-versa).

Jump to

Keyboard shortcuts

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