_123_open

package
v4.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: AGPL-3.0 Imports: 19 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", 4)
	DownloadInfo   = InitApiInfo(Api+"/api/v1/file/download_info", 0)
	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/v1/file/create", 2)
	UploadUrl      = InitApiInfo(Api+"/upload/v1/file/get_upload_url", 0)
	UploadComplete = InitApiInfo(Api+"/upload/v1/file/upload_complete", 0)
	UploadAsync    = InitApiInfo(Api+"/upload/v1/file/upload_async_result", 1)
)

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"`

	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 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
}

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) 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) Upload

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

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 UploadAsyncResp

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

type UploadCompleteResp

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

type UploadCreateResp

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

type UploadResp

type UploadResp struct {
	BaseResp
	Data struct {
		AccessKeyId     string `json:"AccessKeyId"`
		Bucket          string `json:"Bucket"`
		Key             string `json:"Key"`
		SecretAccessKey string `json:"SecretAccessKey"`
		SessionToken    string `json:"SessionToken"`
		FileId          int64  `json:"FileId"`
		Reuse           bool   `json:"Reuse"`
		EndPoint        string `json:"EndPoint"`
		StorageNode     string `json:"StorageNode"`
		UploadId        string `json:"UploadId"`
	} `json:"data"`
}

type UploadUrlResp

type UploadUrlResp struct {
	BaseResp
	Data struct {
		PresignedURL string `json:"presignedURL"`
	}
}

type UserInfoResp

type UserInfoResp struct {
	BaseResp
	Data struct {
		UID            int64  `json:"uid"`
		Username       string `json:"username"`
		DisplayName    string `json:"displayName"`
		HeadImage      string `json:"headImage"`
		Passport       string `json:"passport"`
		Mail           string `json:"mail"`
		SpaceUsed      int64  `json:"spaceUsed"`
		SpacePermanent int64  `json:"spacePermanent"`
		SpaceTemp      int64  `json:"spaceTemp"`
		SpaceTempExpr  string `json:"spaceTempExpr"`
		Vip            bool   `json:"vip"`
		DirectTraffic  int64  `json:"directTraffic"`
		IsHideUID      bool   `json:"isHideUID"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

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