_123_open

package
v4.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: AGPL-3.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Api = "https://open-api.123pan.com"

	AccessToken    = InitApiInfo(Api+"/api/v1/access_token", 1)
	RefreshToken   = InitApiInfo(Api+"/api/v1/oauth2/access_token", 1)
	UserInfo       = InitApiInfo(Api+"/api/v1/user/info", 1)
	FileList       = InitApiInfo(Api+"/api/v2/file/list", 3)
	DownloadInfo   = InitApiInfo(Api+"/api/v1/file/download_info", 5)
	DirectLink     = InitApiInfo(Api+"/api/v1/direct-link/url", 5)
	Mkdir          = InitApiInfo(Api+"/upload/v1/file/mkdir", 2)
	Move           = InitApiInfo(Api+"/api/v1/file/move", 1)
	Rename         = InitApiInfo(Api+"/api/v1/file/name", 1)
	Trash          = InitApiInfo(Api+"/api/v1/file/trash", 2)
	UploadCreate   = InitApiInfo(Api+"/upload/v2/file/create", 2)
	UploadComplete = InitApiInfo(Api+"/upload/v2/file/upload_complete", 0)
)

Functions

This section is empty.

Types

type AccessTokenResp

type AccessTokenResp struct {
	BaseResp
	Data struct {
		AccessToken string `json:"accessToken"`
		ExpiredAt   string `json:"expiredAt"`
	} `json:"data"`
}

type Addition

type Addition struct {
	//  refresh_token方式的AccessToken  【对个人开发者暂未开放】
	RefreshToken string `json:"RefreshToken" required:"false"`

	//  通过 https://www.123pan.com/developer 申请
	ClientID     string `json:"ClientID" required:"false"`
	ClientSecret string `json:"ClientSecret" required:"false"`

	//  直接写入AccessToken
	AccessToken string `json:"AccessToken" required:"false"`

	//  上传线程数
	UploadThread int `json:"UploadThread" type:"number" default:"3" help:"the threads of upload"`

	//  使用直链
	DirectLink              bool   `json:"DirectLink" type:"bool" default:"false" required:"false" help:"use direct link when download file"`
	DirectLinkPrivateKey    string `json:"DirectLinkPrivateKey" required:"false" help:"private key for direct link, if URL authentication is enabled"`
	DirectLinkValidDuration int64  `json:"DirectLinkValidDuration" type:"number" default:"30" required:"false" help:"minutes, if URL authentication is enabled"`

	driver.RootID
}

type ApiInfo

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

func InitApiInfo

func InitApiInfo(url string, qps int) *ApiInfo

func (*ApiInfo) NowLen

func (a *ApiInfo) NowLen() int

func (*ApiInfo) Release

func (a *ApiInfo) Release()

func (*ApiInfo) Require

func (a *ApiInfo) Require()

func (*ApiInfo) SetQPS

func (a *ApiInfo) SetQPS(qps int)

type BaseResp

type BaseResp struct {
	Code     int    `json:"code"`
	Message  string `json:"message"`
	XTraceID string `json:"x-traceID"`
}

type DirectLinkResp added in v4.1.2

type DirectLinkResp struct {
	BaseResp
	Data struct {
		URL string `json:"url"`
	} `json:"data"`
}

type DownloadInfoResp

type DownloadInfoResp struct {
	BaseResp
	Data struct {
		DownloadUrl string `json:"downloadUrl"`
	} `json:"data"`
}

type File

type File struct {
	FileName     string `json:"filename"`
	Size         int64  `json:"size"`
	CreateAt     string `json:"createAt"`
	UpdateAt     string `json:"updateAt"`
	FileId       int64  `json:"fileId"`
	Type         int    `json:"type"`
	Etag         string `json:"etag"`
	S3KeyFlag    string `json:"s3KeyFlag"`
	ParentFileId int    `json:"parentFileId"`
	Category     int    `json:"category"`
	Status       int    `json:"status"`
	Trashed      int    `json:"trashed"`
}

func (File) CreateTime

func (f File) CreateTime() time.Time

func (File) GetHash

func (f File) GetHash() utils.HashInfo

func (File) GetID

func (f File) GetID() string

func (File) GetName

func (f File) GetName() string

func (File) GetPath

func (f File) GetPath() string

func (File) GetSize

func (f File) GetSize() int64

func (File) IsDir

func (f File) IsDir() bool

func (File) ModTime

func (f File) ModTime() time.Time

type FileListResp

type FileListResp struct {
	BaseResp
	Data struct {
		LastFileId int64  `json:"lastFileId"`
		FileList   []File `json:"fileList"`
	} `json:"data"`
}

type Open123

type Open123 struct {
	model.Storage
	Addition
	UID uint64
}

func (*Open123) Config

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

func (*Open123) Copy

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

func (*Open123) Drop

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

func (*Open123) GetAddition

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

func (*Open123) Init

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

func (*Open123) List

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

func (*Open123) MakeDir

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

func (*Open123) Move

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

func (*Open123) Put

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

func (*Open123) Remove

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

func (*Open123) Rename

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

func (*Open123) Request

func (d *Open123) Request(apiInfo *ApiInfo, method string, callback base.ReqCallback, resp interface{}) ([]byte, error)

func (*Open123) SignURL added in v4.1.2

func (d *Open123) SignURL(originURL, privateKey string, uid uint64, validDuration time.Duration) (newURL string, err error)

func (*Open123) Upload

func (d *Open123) Upload(ctx context.Context, file model.FileStreamer, createResp *UploadCreateResp, up driver.UpdateProgress) error

上传分片 V2

type RefreshTokenResp

type RefreshTokenResp struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	TokenType    string `json:"token_type"`
}

type UploadCompleteResp

type UploadCompleteResp struct {
	BaseResp
	Data struct {
		Completed bool  `json:"completed"`
		FileID    int64 `json:"fileID"`
	} `json:"data"`
}

上传完毕V2返回

type UploadCreateResp

type UploadCreateResp struct {
	BaseResp
	Data struct {
		FileID      int64    `json:"fileID"`
		PreuploadID string   `json:"preuploadID"`
		Reuse       bool     `json:"reuse"`
		SliceSize   int64    `json:"sliceSize"`
		Servers     []string `json:"servers"`
	} `json:"data"`
}

创建文件V2返回

type UserInfoResp

type UserInfoResp struct {
	BaseResp
	Data struct {
		UID uint64 `json:"uid"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

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