baidu

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRefreshTokenExpired = errors.New("refresh_token expired")
	ErrAccessTokenEmpty    = errors.New("user not authorized ")
	ErrAccessTokenExpired  = errors.New("access token expired")
)

Functions

func FilterEmoji added in v1.0.3

func FilterEmoji(content string) string

FilterEmoji 过滤 emoji 表情

Types

type CreateFile

type CreateFile struct {
	UploadFileInfo
	ErrNo          int    `json:"errno"`
	ServerFilename string `json:"server_filename"`
}

func (*CreateFile) String

func (p *CreateFile) String() string

type CreateFileParam

type CreateFileParam struct {
	Path       string   `json:"path"`
	Size       int      `json:"size"`
	IsDir      bool     `json:"isdir"`
	RType      int      `json:"rtype"`
	UploadId   string   `json:"uploadid"`
	BlockList  []string `json:"block_list"`
	LocalCTime int64    `json:"local_ctime"`
	LocalMTime int64    `json:"local_mtime"`
	ZipQuality int      `json:"zip_quality"`
	ZipSign    string   `json:"zip_sign"`
	IsRevision int      `json:"is_revision"`
	Mode       int      `json:"mode"`
	ExifInfo   string   `json:"exif_info"`
}

func NewCreateFileParam

func NewCreateFileParam(path string, size int, isDir bool) *CreateFileParam

func (*CreateFileParam) String

func (p *CreateFileParam) String() string

func (*CreateFileParam) Values

func (p *CreateFileParam) Values() url.Values

type ErrorResponse

type ErrorResponse struct {
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
	TokenResponse
}

func (*ErrorResponse) String

func (e *ErrorResponse) String() string

type NetDisk added in v1.0.3

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

func NewNetDisk added in v1.0.3

func NewNetDisk(appId, appKey, secretKey, signKey string) *NetDisk

func (*NetDisk) AuthorizeURI added in v1.0.3

func (d *NetDisk) AuthorizeURI(registeredUrl string, display string) string

AuthorizeURI 获取用户授权页面.

func (*NetDisk) AutoRefreshToken added in v1.0.3

func (d *NetDisk) AutoRefreshToken(ctx context.Context) error

func (*NetDisk) CreateFile added in v1.0.3

func (d *NetDisk) CreateFile(uploadFile *CreateFileParam) (*CreateFile, error)

func (*NetDisk) GetAccessToken added in v1.0.3

func (d *NetDisk) GetAccessToken(code, registeredUrl string) (*TokenResponse, error)

GetAccessToken 获取access_token值.

func (*NetDisk) IsDebug added in v1.0.3

func (d *NetDisk) IsDebug(isDebug bool)

func (*NetDisk) PreCreate added in v1.0.3

func (d *NetDisk) PreCreate(uploadFile *PreCreateUploadFileParam) (*PreCreateUploadFile, error)

PreCreate 预创建文件.

func (*NetDisk) RefreshToken added in v1.0.3

func (d *NetDisk) RefreshToken(force bool) error

RefreshToken 刷新access_token值.

func (*NetDisk) SetAccessToken added in v1.0.3

func (d *NetDisk) SetAccessToken(token *TokenResponse)

func (*NetDisk) UploadFile added in v1.0.3

func (d *NetDisk) UploadFile(uploadFile *PreCreateUploadFile, localFile string) ([]SuperFile, error)

UploadFile 上传指定路径的文件.

func (*NetDisk) UploadFiles added in v1.0.3

func (d *NetDisk) UploadFiles(uploadFile *PreCreateUploadFile, reader io.Reader) ([]SuperFile, error)

UploadFiles 批量上传文件.

func (*NetDisk) UserInfo added in v1.0.3

func (d *NetDisk) UserInfo() (*UserInfo, error)

UserInfo 获取用户信息.

type PreCreateUploadFile

type PreCreateUploadFile struct {
	ErrNo      int            `json:"errno"`
	Path       string         `json:"path"`
	UploadId   string         `json:"uploadid"`
	ReturnType int            `json:"return_type"`
	BlockList  []int          `json:"block_list"`
	Info       UploadFileInfo `json:"info,omitempty"`
}

func (*PreCreateUploadFile) String

func (u *PreCreateUploadFile) String() string

type PreCreateUploadFileParam

type PreCreateUploadFileParam struct {
	Path       string   `json:"path"`
	Size       int      `json:"size"`
	IsDir      bool     `json:"is_dir"`
	AutoInit   int      `json:"autoinit"`
	RType      int      `json:"rtype"`
	UploadId   string   `json:"uploadid"`
	BlockList  []string `json:"block_list"`
	ContentMD5 string   `json:"content_md5"`
	SliceMD5   string   `json:"slice_md5"`
	LocalCTime int64    `json:"local_ctime"`
	LocalMTime int64    `json:"local_mtime"`
}

func NewPreCreateUploadFileParam

func NewPreCreateUploadFileParam(filename string, path string) (*PreCreateUploadFileParam, error)

func (*PreCreateUploadFileParam) String

func (u *PreCreateUploadFileParam) String() string

func (*PreCreateUploadFileParam) Values

func (u *PreCreateUploadFileParam) Values() url.Values

type SuperFile

type SuperFile struct {
	ErrorNo   int    `json:"error_code"`
	ErrorMsg  string `json:"error_msg"`
	Md5       string `json:"md5"`
	RequestId uint64 `json:"request_id"`
}

type SuperFileParam

type SuperFileParam struct {
	AccessToken string
	Method      string
	Type        string
	Path        string
	UploadId    string
	PartSeq     int
}

func (*SuperFileParam) Values

func (s *SuperFileParam) Values() url.Values

type TokenResponse

type TokenResponse struct {
	AccessToken          string `json:"access_token"`
	ExpiresIn            int64  `json:"expires_in"`
	RefreshToken         string `json:"refresh_token"`
	Scope                string `json:"scope"`
	SessionKey           string `json:"session_key"`
	SessionSecret        string `json:"session_secret"`
	CreateAt             int64  `json:"-"`
	RefreshTokenCreateAt int64  `json:"-"`
}

func (*TokenResponse) Clone

func (t *TokenResponse) Clone() *TokenResponse

func (*TokenResponse) IsExpired

func (t *TokenResponse) IsExpired() bool

func (*TokenResponse) IsRefreshTokenExpired

func (t *TokenResponse) IsRefreshTokenExpired() bool

type UploadFileInfo

type UploadFileInfo struct {
	Size     int    `json:"size"`
	Category int    `json:"category"`
	IsDir    int    `json:"is_dir"`
	Path     string `json:"path"`
	FsId     int64  `json:"fs_id"`
	MD5      string `json:"md5"`
	CTime    int64  `json:"ctime"`
	MTime    int64  `json:"mtime"`
}

func (UploadFileInfo) String

func (f UploadFileInfo) String() string

type UserInfo

type UserInfo struct {
	ErrNo       int    `json:"errno"`
	ErrMsg      string `json:"errmsg"`
	BaiduName   string `json:"baidu_name"`
	NetdiskName string `json:"netdisk_name"`
	AvatarUrl   string `json:"avatar_url"`
	VipType     int    `json:"vip_type"`
	UserId      int    `json:"uk"`
}

func (*UserInfo) Clone

func (u *UserInfo) Clone() *UserInfo

func (*UserInfo) String

func (u *UserInfo) String() string

Jump to

Keyboard shortcuts

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