baiduphoto

package
v3.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: AGPL-3.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	API_URL         = "https://photo.baidu.com/youai"
	ALBUM_API_URL   = API_URL + "/album/v1"
	FILE_API_URL_V1 = API_URL + "/file/v1"
	FILE_API_URL_V2 = API_URL + "/file/v2"
)

Variables

View Source
var (
	ErrNotSupportName = errors.New("only chinese and english, numbers and underscores are supported, and the length is no more than 20")
)

Functions

func IsAlbum

func IsAlbum(obj model.Obj) bool

相册

func IsAlbumFile

func IsAlbumFile(obj model.Obj) bool

相册文件

func IsAlbumRoot

func IsAlbumRoot(obj model.Obj) bool

以相册为根目录

func IsFile

func IsFile(obj model.Obj) bool

根文件

func IsRoot

func IsRoot(obj model.Obj) bool

根目录

func MustString

func MustString(str string, err error) string

Types

type Addition

type Addition struct {
	RefreshToken string `json:"refresh_token" required:"true"`
	ShowType     string `json:"show_type" type:"select" options:"root,root_only_album,root_only_file" default:"root"`
	AlbumID      string `json:"album_id"`
	//AlbumPassword string `json:"album_password"`
	ClientID     string `json:"client_id" required:"true" default:"iYCeC9g08h5vuP9UqvPHKKSVrKFXGa1v"`
	ClientSecret string `json:"client_secret" required:"true" default:"jXiFMOPVPCWlO2M5CwWQzffpNPaGTRBG"`
}

func (Addition) GetRootId

func (a Addition) GetRootId() string

type Album

type Album struct {
	AlbumID    string `json:"album_id"`
	Tid        int64  `json:"tid"`
	Title      string `json:"title"`
	JoinTime   int64  `json:"join_time"`
	CreateTime int64  `json:"create_time"`
	Mtime      int64  `json:"mtime"`
	// contains filtered or unexported fields
}

相册部分

func (*Album) GetID

func (a *Album) GetID() string

func (*Album) GetName

func (a *Album) GetName() string

func (*Album) GetPath

func (a *Album) GetPath() string

func (*Album) GetSize

func (a *Album) GetSize() int64

func (*Album) IsDir

func (a *Album) IsDir() bool

func (*Album) ModTime

func (a *Album) ModTime() time.Time

type AlbumFile

type AlbumFile struct {
	File
	AlbumID string `json:"album_id"`
	Tid     int64  `json:"tid"`
	Uk      int64  `json:"uk"`
}

相册部分

func (*AlbumFile) GetID

func (af *AlbumFile) GetID() string

func (*AlbumFile) GetPath

func (c *AlbumFile) GetPath() string

type AlbumFileListResp

type AlbumFileListResp struct {
	Page
	List       []AlbumFile `json:"list"`
	Reset      int64       `json:"reset"`
	TotalCount int64       `json:"total_count"`
}

相册部分

type AlbumListResp

type AlbumListResp struct {
	Page
	List       []Album `json:"list"`
	Reset      int64   `json:"reset"`
	TotalCount int64   `json:"total_count"`
}

相册部分

type BaiduPhoto

type BaiduPhoto struct {
	model.Storage
	Addition

	AccessToken string
}

func (*BaiduPhoto) AddAlbumFile

func (p *BaiduPhoto) AddAlbumFile(ctx context.Context, albumID, tID string, fileIDs ...string) error

增加相册文件

func (*BaiduPhoto) Config

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

func (*BaiduPhoto) Copy

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

func (*BaiduPhoto) CopyAlbumFile

func (p *BaiduPhoto) CopyAlbumFile(ctx context.Context, albumID, tID, uk string, fileID ...string) (*CopyFile, error)

保存相册文件为根文件

func (*BaiduPhoto) CreateAlbum

func (p *BaiduPhoto) CreateAlbum(ctx context.Context, name string) error

创建相册

func (*BaiduPhoto) DeleteAlbum

func (p *BaiduPhoto) DeleteAlbum(ctx context.Context, albumID, tID string) error

删除相册

func (*BaiduPhoto) DeleteAlbumFile

func (p *BaiduPhoto) DeleteAlbumFile(ctx context.Context, albumID, tID string, fileIDs ...string) error

删除相册文件

func (*BaiduPhoto) DeleteFile

func (p *BaiduPhoto) DeleteFile(ctx context.Context, fileIDs ...string) error

删除根文件

func (*BaiduPhoto) Drop

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

func (*BaiduPhoto) Get

func (p *BaiduPhoto) Get(furl string, callback base.ReqCallback, resp interface{}) ([]byte, error)

func (*BaiduPhoto) GetAddition

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

func (*BaiduPhoto) GetAllAlbum

func (p *BaiduPhoto) GetAllAlbum(ctx context.Context) (albums []Album, err error)

获取所有相册

func (*BaiduPhoto) GetAllAlbumFile

func (p *BaiduPhoto) GetAllAlbumFile(ctx context.Context, albumID, passwd string) (files []AlbumFile, err error)

获取相册中所有文件

func (*BaiduPhoto) GetAllFile

func (p *BaiduPhoto) GetAllFile(ctx context.Context) (files []File, err error)

获取所有文件

func (*BaiduPhoto) Init

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

func (*BaiduPhoto) JoinAlbum

func (p *BaiduPhoto) JoinAlbum(ctx context.Context, code string) error

加入相册

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

func (*BaiduPhoto) List

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

func (*BaiduPhoto) MakeDir

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

func (*BaiduPhoto) Move

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

func (*BaiduPhoto) Post

func (p *BaiduPhoto) Post(furl string, callback base.ReqCallback, resp interface{}) ([]byte, error)

func (*BaiduPhoto) Put

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

func (*BaiduPhoto) Remove

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

func (*BaiduPhoto) Rename

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

func (*BaiduPhoto) Request

func (p *BaiduPhoto) Request(furl string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error)

func (*BaiduPhoto) SetAlbumName

func (p *BaiduPhoto) SetAlbumName(ctx context.Context, albumID, tID, name string) error

相册改名

type CopyFile

type CopyFile struct {
	FromFsid  int64  `json:"from_fsid"` // 源ID
	Fsid      int64  `json:"fsid"`      // 目标ID
	Path      string `json:"path"`
	ShootTime int    `json:"shoot_time"`
}

type CopyFileResp

type CopyFileResp struct {
	List []CopyFile `json:"list"`
}

type CreateFileResp

type CreateFileResp struct {
	Data UploadFile `json:"data"`
}

上传部分

type Erron

type Erron struct {
	Errno     int `json:"errno"`
	RequestID int `json:"request_id"`
}

type File

type File struct {
	Fsid     int64    `json:"fsid"` // 文件ID
	Path     string   `json:"path"` // 文件路径
	Size     int64    `json:"size"`
	Ctime    int64    `json:"ctime"` // 创建时间 s
	Mtime    int64    `json:"mtime"` // 修改时间 s
	Thumburl []string `json:"thumburl"`
	// contains filtered or unexported fields
}

func (*File) GetID

func (c *File) GetID() string

func (*File) GetName

func (c *File) GetName() string

func (*File) GetPath

func (c *File) GetPath() string

func (*File) GetSize

func (c *File) GetSize() int64

func (*File) IsDir

func (c *File) IsDir() bool

func (*File) ModTime

func (c *File) ModTime() time.Time

func (*File) Thumb

func (c *File) Thumb() string

type FileListResp

type FileListResp struct {
	Page
	List []File `json:"list"`
}

type InviteResp

type InviteResp struct {
	Pdata struct {
		// 邀请码
		InviteCode string `json:"invite_code"`
		// 有效时间
		ExpireTime int    `json:"expire_time"`
		ShareID    string `json:"share_id"`
	} `json:"pdata"`
}

type Page

type Page struct {
	HasMore int    `json:"has_more"`
	Cursor  string `json:"cursor"`
}

func (Page) HasNextPage

func (p Page) HasNextPage() bool

type PrecreateResp

type PrecreateResp struct {
	ReturnType int `json:"return_type"` //存在返回2 不存在返回1 已经保存3
	//存在返回
	CreateFileResp

	//不存在返回
	Path      string  `json:"path"`
	UploadID  string  `json:"uploadid"`
	Blocklist []int64 `json:"block_list"`
}

上传部分

type TokenErrResp

type TokenErrResp struct {
	ErrorDescription string `json:"error_description"`
	ErrorMsg         string `json:"error"`
}

func (*TokenErrResp) Error

func (e *TokenErrResp) Error() string

type UploadFile

type UploadFile struct {
	FsID           int64  `json:"fs_id"`
	Size           int64  `json:"size"`
	Md5            string `json:"md5"`
	ServerFilename string `json:"server_filename"`
	Path           string `json:"path"`
	Ctime          int    `json:"ctime"`
	Mtime          int    `json:"mtime"`
	Isdir          int    `json:"isdir"`
	Category       int    `json:"category"`
	ServerMd5      string `json:"server_md5"`
	ShootTime      int    `json:"shoot_time"`
}

上传部分

Jump to

Keyboard shortcuts

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