_123

package
v4.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Api              = "https://www.123pan.com/api"
	AApi             = "https://www.123pan.com/a/api"
	BApi             = "https://www.123pan.com/b/api"
	LoginApi         = "https://login.123pan.com/api"
	MainApi          = BApi
	SignIn           = LoginApi + "/user/sign_in"
	Logout           = MainApi + "/user/logout"
	UserInfo         = MainApi + "/user/info"
	FileList         = MainApi + "/file/list/new"
	DownloadInfo     = MainApi + "/file/download_info"
	Mkdir            = MainApi + "/file/upload_request"
	Move             = MainApi + "/file/mod_pid"
	Rename           = MainApi + "/file/rename"
	Trash            = MainApi + "/file/trash"
	UploadRequest    = MainApi + "/file/upload_request"
	UploadComplete   = MainApi + "/file/upload_complete"
	S3PreSignedUrls  = MainApi + "/file/s3_repare_upload_parts_batch"
	S3Auth           = MainApi + "/file/s3_upload_object/auth"
	UploadCompleteV2 = MainApi + "/file/upload_complete/v2"
	S3Complete       = MainApi + "/file/s3_complete_multipart_upload"
)

API端点常量定义

Variables

This section is empty.

Functions

func GetApi

func GetApi(rawUrl string) string

GetApi 为API URL添加签名参数 参数:

  • rawUrl: 原始API URL

返回:

  • 添加签名后的URL

Types

type Addition

type Addition struct {
	// 用户名(必填)
	Username string `json:"username" required:"true"`
	// 密码(必填)
	Password string `json:"password" required:"true"`
	// 根目录ID
	driver.RootID
	// 排序字段(已注释掉,可能为未来功能预留)
	// OrderBy        string `json:"order_by" type:"select" options:"file_id,file_name,size,update_at" default:"file_name"`
	// 排序方向(已注释掉,可能为未来功能预留)
	// OrderDirection string `json:"order_direction" type:"select" options:"asc,desc" default:"asc"`
	// 访问令牌,由登录过程获取
	AccessToken string
}

Addition 定义123网盘驱动的额外配置参数

type File

type File struct {
	// 文件名
	FileName string `json:"FileName"`
	// 文件大小(字节)
	Size int64 `json:"Size"`
	// 更新时间
	UpdateAt time.Time `json:"UpdateAt"`
	// 文件ID
	FileId int64 `json:"FileId"`
	// 类型:0-文件,1-目录
	Type int `json:"Type"`
	// 文件的ETag
	Etag string `json:"Etag"`
	// S3存储的键标志
	S3KeyFlag string `json:"S3KeyFlag"`
	// 下载URL
	DownloadUrl string `json:"DownloadUrl"`
}

File 表示123网盘中的文件或目录

func (File) CreateTime

func (f File) CreateTime() time.Time

CreateTime 返回文件的创建时间 注:123网盘API不提供创建时间,使用更新时间代替

func (File) GetHash

func (f File) GetHash() utils.HashInfo

GetHash 返回文件的哈希信息 注:目前未实现,返回空哈希信息

func (File) GetID

func (f File) GetID() string

GetID 返回文件的ID(字符串形式)

func (File) GetName

func (f File) GetName() string

GetName 返回文件的名称

func (File) GetPath

func (f File) GetPath() string

GetPath 返回文件的路径 注:目前未实现,返回空字符串

func (File) GetSize

func (f File) GetSize() int64

GetSize 返回文件的大小

func (File) IsDir

func (f File) IsDir() bool

IsDir 判断是否为目录

func (File) ModTime

func (f File) ModTime() time.Time

ModTime 返回文件的修改时间

func (File) Thumb

func (f File) Thumb() string

Thumb 返回文件的缩略图URL

type Files

type Files struct {
	Data struct {
		// 下一页标识符
		Next string `json:"Next"`
		// 总文件数
		Total int `json:"Total"`
		// 文件列表
		InfoList []File `json:"InfoList"`
	} `json:"data"`
}

Files 表示文件列表响应

type Pan123

type Pan123 struct {
	model.Storage
	Addition
	// contains filtered or unexported fields
}

Pan123 实现123网盘的驱动

func (*Pan123) APIRateLimit

func (d *Pan123) APIRateLimit(ctx context.Context, api string) error

APIRateLimit 实现API请求速率限制

func (*Pan123) Config

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

Config 返回驱动配置

func (*Pan123) Copy

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

Copy 复制文件或目录(不支持)

func (*Pan123) Drop

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

Drop 注销登录

func (*Pan123) GetAddition

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

GetAddition 返回驱动附加配置

func (*Pan123) Init

func (d *Pan123) Init(ctx context.Context) error

Init 初始化驱动,验证凭据有效性

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

Link 获取文件的下载链接

func (*Pan123) List

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

List 列出指定目录下的文件和子目录

func (*Pan123) MakeDir

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

MakeDir 创建目录

func (*Pan123) Move

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

Move 移动文件或目录

func (*Pan123) Put

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

Put 上传文件

func (*Pan123) Remove

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

Remove 删除文件或目录(移至回收站)

func (*Pan123) Rename

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

Rename 重命名文件或目录

func (*Pan123) Request

func (d *Pan123) Request(url string, method string, callback base.ReqCallback, resp any) ([]byte, error)

Request 发送API请求 参数:

  • url: API URL
  • method: HTTP方法
  • callback: 请求回调函数,用于自定义请求
  • resp: 响应结构体指针

返回:

  • 响应体字节数组和可能的错误

type S3PreSignedURLs

type S3PreSignedURLs struct {
	Data struct {
		// 预签名URL映射,键为分片编号,值为URL
		PreSignedUrls map[string]string `json:"presignedUrls"`
	} `json:"data"`
}

S3PreSignedURLs 表示S3预签名URL响应

type UploadResp

type UploadResp struct {
	Data struct {
		// S3访问密钥ID
		AccessKeyId string `json:"AccessKeyId"`
		// S3存储桶名称
		Bucket string `json:"Bucket"`
		// S3对象键
		Key string `json:"Key"`
		// S3访问密钥
		SecretAccessKey string `json:"SecretAccessKey"`
		// S3会话令牌
		SessionToken string `json:"SessionToken"`
		// 文件ID
		FileId int64 `json:"FileId"`
		// 是否重用现有文件
		Reuse bool `json:"Reuse"`
		// S3端点URL
		EndPoint string `json:"EndPoint"`
		// 存储节点
		StorageNode string `json:"StorageNode"`
		// 上传ID
		UploadId string `json:"UploadId"`
	} `json:"data"`
}

UploadResp 表示上传请求的响应

Jump to

Keyboard shortcuts

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