cloudreve

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

cloudreve-client

a cloudreve-client for go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelCache

func DelCache(key string) error

func GetCache

func GetCache[V any](key string, val V) error

func SetCache

func SetCache(key string, value interface{}) error

Types

type CloudreveClient

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

func NewClient

func NewClient(cloudreveUrl, cloudreveSession string) *CloudreveClient

func NewClientWithLogin

func NewClientWithLogin(cloudreveUrl, username, password string) *CloudreveClient

func NewClientWithRefresh

func NewClientWithRefresh(cloudreveUrl, cloudreveSession string, sessionRefresh SessionRefresh) *CloudreveClient

func (*CloudreveClient) Config

func (c *CloudreveClient) Config() (*RespData[SiteConfig], error)

func (*CloudreveClient) CreateDirectory

func (c *CloudreveClient) CreateDirectory(path string) (*Resp, error)

func (*CloudreveClient) Download added in v1.0.4

func (c *CloudreveClient) Download(req OneStepDownloadReq) error

func (*CloudreveClient) FileArchive

func (c *CloudreveClient) FileArchive(req ItemReq) (*RespData[string], error)

func (*CloudreveClient) FileCreateDownloadSession

func (c *CloudreveClient) FileCreateDownloadSession(id string) (*RespData[string], error)

func (*CloudreveClient) FileCreateFile

func (c *CloudreveClient) FileCreateFile(path string) (*Resp, error)

func (*CloudreveClient) FileGetSource

func (c *CloudreveClient) FileGetSource(req ItemReq) (*RespData[[]Sources], error)

func (*CloudreveClient) FileUploadDeleteAllUploadSession

func (c *CloudreveClient) FileUploadDeleteAllUploadSession() (*Resp, error)

func (*CloudreveClient) FileUploadDeleteUploadSession

func (c *CloudreveClient) FileUploadDeleteUploadSession(sessionId string) (*Resp, error)

func (*CloudreveClient) FileUploadGetUploadSession

func (c *CloudreveClient) FileUploadGetUploadSession(req CreateUploadSessionReq) (*RespData[UploadCredential], error)

func (*CloudreveClient) ListDirectory

func (c *CloudreveClient) ListDirectory(path string) (*RespData[ObjectList], error)

func (*CloudreveClient) ObjectCopy

func (c *CloudreveClient) ObjectCopy(req ItemMoveReq) (*Resp, error)

func (*CloudreveClient) ObjectDelete

func (c *CloudreveClient) ObjectDelete(req ItemReq) (*Resp, error)

func (*CloudreveClient) ObjectGetProperty

func (c *CloudreveClient) ObjectGetProperty(req ItemPropertyReq) (*RespData[ObjectProps], error)

func (*CloudreveClient) ObjectMove

func (c *CloudreveClient) ObjectMove(req ItemMoveReq) (*Resp, error)

func (*CloudreveClient) ObjectRename

func (c *CloudreveClient) ObjectRename(req ItemRenameReq) (*Resp, error)

func (*CloudreveClient) OneDriveCallback

func (c *CloudreveClient) OneDriveCallback(sessionId string) (*Resp, error)

func (*CloudreveClient) OneDriveUpload

func (c *CloudreveClient) OneDriveUpload(req OneDriveUploadReq) (int64, error)

OneDriveUpload 分片上传 返回已上传的字节数和错误信息

func (*CloudreveClient) Rename added in v1.0.4

func (c *CloudreveClient) Rename(path string, fn RenameDealFunc) error

Rename 一键重命名

func (*CloudreveClient) ShareCreateShare

func (c *CloudreveClient) ShareCreateShare(req ShareCreateReq) (*RespData[string], error)

func (*CloudreveClient) ShareDeleteShare

func (c *CloudreveClient) ShareDeleteShare(id string) (*Resp, error)

func (*CloudreveClient) ShareGetShare

func (c *CloudreveClient) ShareGetShare(id, password string) (*RespData[Share], error)

func (*CloudreveClient) ShareGetShareDownload

func (c *CloudreveClient) ShareGetShareDownload(id, path string) (*RespData[string], error)

func (*CloudreveClient) ShareListShare

func (c *CloudreveClient) ShareListShare() (*RespData[ShareList], error)

func (*CloudreveClient) ShareListSharedFolder

func (c *CloudreveClient) ShareListSharedFolder(id, path string) (*RespData[ObjectList], error)

func (*CloudreveClient) ShareSearchShare

func (c *CloudreveClient) ShareSearchShare(req ShareListReq) (*RespData[ShareList], error)

func (*CloudreveClient) ShareSearchSharedFolder

func (c *CloudreveClient) ShareSearchSharedFolder(id, keyword, path string, searchType SearchType) (*RespData[ObjectList], error)

func (*CloudreveClient) ShareUpdateShare

func (c *CloudreveClient) ShareUpdateShare(req ShareUpdateReq) (*RespData[string], error)

func (*CloudreveClient) UploadFile

func (c *CloudreveClient) UploadFile(req OneStepUploadFileReq) error

UploadFile 一键上传文件

func (*CloudreveClient) UploadPath

func (c *CloudreveClient) UploadPath(req OneStepUploadPathReq) error

UploadPath 一键上传路径

func (*CloudreveClient) UserStorage

func (c *CloudreveClient) UserStorage() (*RespData[Storage], error)

type CreateUploadSessionReq

type CreateUploadSessionReq struct {
	Path         string `json:"path"`
	Size         uint64 `json:"size"`
	Name         string `json:"name" `
	PolicyID     string `json:"policy_id" `
	LastModified int64  `json:"last_modified"`
	MimeType     string `json:"mime_type"`
}

CreateUploadSessionReq 获取上传凭证服务

type DownloadCallback added in v1.0.4

type DownloadCallback func(localPath, localFile string)

type Item

type Item struct {
	Items []string `json:"items"`
	Dirs  []string `json:"dirs"`
}

Item 处理多文件/目录相关服务

type ItemMoveReq

type ItemMoveReq struct {
	SrcDir string `json:"src_dir"`
	Src    Item   `json:"src"`
	Dst    string `json:"dst" `
}

ItemMoveReq 处理多文件/目录移动

type ItemPropertyReq

type ItemPropertyReq struct {
	Id        string
	TraceRoot bool
	IsFolder  bool
}

ItemPropertyReq 获取对象属性服务

type ItemRenameReq

type ItemRenameReq struct {
	Src     Item   `json:"src"`
	NewName string `json:"new_name" `
}

ItemRenameReq 处理多文件/目录重命名

type ItemReq

type ItemReq struct {
	Item
	Force      bool `json:"force"`
	UnlinkOnly bool `json:"unlink"`
}

ItemReq 处理多文件/目录

type Json

type Json map[string]interface{}

type MyShareItem

type MyShareItem struct {
	Key             string       `json:"key"`
	IsDir           bool         `json:"is_dir"`
	Password        string       `json:"password"`
	CreateDate      time.Time    `json:"create_date,omitempty"`
	Downloads       int          `json:"downloads"`
	RemainDownloads int          `json:"remain_downloads"`
	Views           int          `json:"views"`
	Expire          int64        `json:"expire"`
	Preview         bool         `json:"preview"`
	Source          *ShareSource `json:"source,omitempty"`
}

MyShareItem 我的分享列表条目

type Object

type Object struct {
	ID            string    `json:"id"`
	Name          string    `json:"name"`
	Path          string    `json:"path"`
	Thumb         bool      `json:"thumb"`
	Size          uint64    `json:"size"`
	Type          string    `json:"type"`
	Date          time.Time `json:"date"`
	CreateDate    time.Time `json:"create_date"`
	Key           string    `json:"key,omitempty"`
	SourceEnabled bool      `json:"source_enabled"`
}

Object 文件或者目录

type ObjectList

type ObjectList struct {
	Parent  string         `json:"parent,omitempty"`
	Objects []Object       `json:"objects"`
	Policy  *PolicySummary `json:"policy,omitempty"`
}

ObjectList 文件、目录列表

type ObjectProps

type ObjectProps struct {
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	Policy         string    `json:"policy"`
	Size           uint64    `json:"size"`
	ChildFolderNum int       `json:"child_folder_num"`
	ChildFileNum   int       `json:"child_file_num"`
	Path           string    `json:"path"`

	QueryDate time.Time `json:"query_date"`
}

ObjectProps 文件、目录对象的详细属性信息

type OneDriveUploadReq

type OneDriveUploadReq struct {
	UploadUrl    string
	LocalFile    *os.File
	UploadedSize int64
	ChunkSize    int64
}

type OneStepDownloadReq added in v1.0.4

type OneStepDownloadReq struct {
	Remote           string
	LocalPath        string
	IsParallel       bool
	SegmentSize      int64
	DownloadCallback DownloadCallback
}

type OneStepUploadFileReq

type OneStepUploadFileReq struct {
	LocalFile      string
	RemotePath     string
	PolicyId       string
	Resumable      bool
	SuccessDel     bool
	RemoteTransfer func(remotePath, remoteName string) (string, string)
}

type OneStepUploadPathReq

type OneStepUploadPathReq struct {
	LocalPath        string
	RemotePath       string
	PolicyId         string
	Resumable        bool
	SkipFileErr      bool
	SuccessDel       bool
	IgnorePaths      []string
	IgnoreFiles      []string
	Extensions       []string
	IgnoreExtensions []string
	RemoteTransfer   func(remotePath, remoteName string) (string, string)
}

type PolicySummary

type PolicySummary struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Type     string   `json:"type"`
	MaxSize  uint64   `json:"max_size"`
	FileType []string `json:"file_type"`
}

PolicySummary 用于前端组件使用的存储策略概况

type ProgressReader

type ProgressReader struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

func (*ProgressReader) Read

func (pr *ProgressReader) Read(p []byte) (n int, err error)

type RenameDealFunc

type RenameDealFunc func(obj Object) string

type Resp

type Resp struct {
	Code  int    `json:"code"`
	Msg   string `json:"msg"`
	Error string `json:"error,omitempty"`
}

Resp 基础序列化器

type RespData

type RespData[T any] struct {
	Code  int    `json:"code"`
	Msg   string `json:"msg"`
	Error string `json:"error,omitempty"`
	Data  T      `json:"data,omitempty"`
}

RespData 基础序列化器

type SearchOrder

type SearchOrder string

SearchOrder 排序

const (
	DESC SearchOrder = "DESC"
	ASC  SearchOrder = "ASC"
)

查询类型枚举值

type SearchOrderBy

type SearchOrderBy string

SearchOrderBy 排序

const (
	CREATED_AT SearchOrderBy = "created_at"
	DOWNLOADS  SearchOrderBy = "downloads"
	VIEWS      SearchOrderBy = "views"
)

查询类型枚举值

type SearchType

type SearchType string

SearchType 查询类型

const (
	KEYWORDS SearchType = "keywords"
	IMAGE    SearchType = "image"
	VIDEO    SearchType = "video"
	AUDIO    SearchType = "audio"
	DOC      SearchType = "doc"
	TAG      SearchType = "tag"
)

查询类型枚举值

type SessionRefresh

type SessionRefresh func(session string)

type Share

type Share struct {
	Key        string        `json:"key"`
	Locked     bool          `json:"locked"`
	IsDir      bool          `json:"is_dir"`
	CreateDate time.Time     `json:"create_date,omitempty"`
	Downloads  int           `json:"downloads"`
	Views      int           `json:"views"`
	Expire     int64         `json:"expire"`
	Preview    bool          `json:"preview"`
	Creator    *ShareCreator `json:"creator,omitempty"`
	Source     *ShareSource  `json:"source,omitempty"`
}

Share 分享信息序列化

type ShareCreateReq

type ShareCreateReq struct {
	SourceID        string `json:"id"`
	IsDir           bool   `json:"is_dir"`
	Password        string `json:"password"`
	RemainDownloads int    `json:"downloads"`
	Expire          int    `json:"expire"`
	Preview         bool   `json:"preview"`
}

ShareCreateReq 创建新分享服务

type ShareCreator

type ShareCreator struct {
	Key       string `json:"key"`
	Nick      string `json:"nick"`
	GroupName string `json:"group_name"`
}

type ShareList

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

type ShareListReq

type ShareListReq struct {
	Page     uint
	OrderBy  SearchOrderBy `binding:"required,eq=created_at|eq=downloads|eq=views"`
	Order    SearchOrder   `binding:"required,eq=DESC|eq=ASC"`
	Keywords string
}

ShareListReq 列出分享

type ShareSource

type ShareSource struct {
	Name string `json:"name"`
	Size uint64 `json:"size"`
}

type ShareUpdateReq

type ShareUpdateReq struct {
	Id    string             `json:"id"`
	Prop  ShareUpdateReqProp `json:"prop"`
	Value string             `json:"value"`
}

ShareUpdateReq 分享更新服务

type ShareUpdateReqProp

type ShareUpdateReqProp string

定义枚举类型

const (
	Password       ShareUpdateReqProp = "password"
	PreviewEnabled ShareUpdateReqProp = "preview_enabled"
)

定义枚举值

type SiteConfig

type SiteConfig struct {
	SiteName             string   `json:"title"`
	LoginCaptcha         bool     `json:"loginCaptcha"`
	RegCaptcha           bool     `json:"regCaptcha"`
	ForgetCaptcha        bool     `json:"forgetCaptcha"`
	EmailActive          bool     `json:"emailActive"`
	Themes               string   `json:"themes"`
	DefaultTheme         string   `json:"defaultTheme"`
	HomepageViewMethod   string   `json:"home_view_method"`
	ShareViewMethod      string   `json:"share_view_method"`
	Authn                bool     `json:"authn"`
	User                 User     `json:"user"`
	ReCaptchaKey         string   `json:"captcha_ReCaptchaKey"`
	CaptchaType          string   `json:"captcha_type"`
	TCaptchaCaptchaAppId string   `json:"tcaptcha_captcha_app_id"`
	RegisterEnabled      bool     `json:"registerEnabled"`
	AppPromotion         bool     `json:"app_promotion"`
	WopiExts             []string `json:"wopi_exts"`
}

type Sources

type Sources struct {
	URL    string `json:"url"`
	Name   string `json:"name"`
	Parent uint   `json:"parent"`
	Error  string `json:"error,omitempty"`
}

Sources 获取外链的结果响应

type Storage

type Storage struct {
	Used  uint64 `json:"used"`
	Free  uint64 `json:"free"`
	Total uint64 `json:"total"`
}

type Tag

type Tag struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Icon       string `json:"icon"`
	Color      string `json:"color"`
	Type       int    `json:"type"`
	Expression string `json:"expression"`
}

type UploadCredential

type UploadCredential struct {
	SessionID   string   `json:"sessionID"`
	ChunkSize   uint64   `json:"chunkSize"` // 分块大小,0 为部分快
	Expires     int64    `json:"expires"`   // 上传凭证过期时间, Unix 时间戳
	UploadURLs  []string `json:"uploadURLs,omitempty"`
	Credential  string   `json:"credential,omitempty"`
	UploadID    string   `json:"uploadID,omitempty"`
	Callback    string   `json:"callback,omitempty"` // 回调地址
	Path        string   `json:"path,omitempty"`     // 存储路径
	AccessKey   string   `json:"ak,omitempty"`
	KeyTime     string   `json:"keyTime,omitempty"` // COS用有效期
	Policy      string   `json:"policy,omitempty"`
	CompleteURL string   `json:"completeURL,omitempty"`
}

UploadCredential 返回给客户端的上传凭证

type User

type User struct {
	ID             string    `json:"id"`
	Email          string    `json:"user_name"`
	Nickname       string    `json:"nickname"`
	Status         int       `json:"status"`
	Avatar         string    `json:"avatar"`
	CreatedAt      time.Time `json:"created_at"`
	PreferredTheme string    `json:"preferred_theme"`
	Anonymous      bool      `json:"anonymous"`
	Group          group     `json:"group"`
	Tags           []Tag     `json:"tags"`
}

User 用户序列化器

Jump to

Keyboard shortcuts

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