aliyundrive

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: Apache-2.0 Imports: 26 Imported by: 5

README

go-aliyundrive

阿里云盘 Go SDK

安装

go get github.com/chyroc/go-aliyundrive

使用

初始化 SDK 实例
ins := aliyundrive.New()

// 下面所有提到的 ins 都是指这个实例
登录

具体代码参考这里

user, err := ins.Auth.LoginByQrcode(context.TODO())
读取文件

具体代码参考这里

resp, err := ins.File.GetFileList(context.TODO(), &aliyundrive.GetFileListReq{
    DriveID:      driveID,
    ParentFileID: parentID,
    Marker:       next,
})
获取分享的内容

具体代码参考这里

sharedInfo, err := ins.ShareLink.GetShareByAnonymous(ctx, &aliyundrive.GetShareByAnonymousReq{
    ShareID: shareID,
})

其他

Documentation

Overview

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

*

  • Copyright 2022 chyroc *
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at *
  • http://www.apache.org/licenses/LICENSE-2.0 *
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.

Index

Constants

View Source
const RootFileID = "root"

Variables

This section is empty.

Functions

func IsTokenExpired

func IsTokenExpired(err error) bool

Types

type AliyunDrive

type AliyunDrive struct {

	// service
	ShareLink *ShareLinkService
	Auth      *AuthService
	File      *FileService
	// contains filtered or unexported fields
}

func New

func New(options ...ClientOptionFunc) *AliyunDrive

func (*AliyunDrive) RawRequest

func (r *AliyunDrive) RawRequest(ctx context.Context, req *RawRequestReq, resp interface{}) (*Response, error)

type AuthService

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

func (*AuthService) GetSelfUser

func (r *AuthService) GetSelfUser(ctx context.Context) (*GetSelfUserResp, error)

func (*AuthService) LoginByQrcode

func (r *AuthService) LoginByQrcode(ctx context.Context, request *LoginByQrcodeReq) (*GetSelfUserResp, error)

func (*AuthService) RefreshToken

func (r *AuthService) RefreshToken(ctx context.Context, request *RefreshTokenReq) (*RefreshTokenResp, error)

type ClientOptionFunc

type ClientOptionFunc func(*AliyunDrive)

func WithLogger

func WithLogger(logger Logger, level LogLevel) ClientOptionFunc

func WithStore added in v0.2.0

func WithStore(store Store) ClientOptionFunc

func WithWorkDir

func WithWorkDir(dir string) ClientOptionFunc

type CreateFolderReq

type CreateFolderReq struct {
	DriveID       string   `json:"drive_id"`
	ParentFileID  string   `json:"parent_file_id"`
	Name          string   `json:"name"`
	CheckNameMode string   `json:"check_name_mode"`
	Type          FileType `json:"type"`
}

type CreateFolderResp

type CreateFolderResp struct {
	ParentFileID string   `json:"parent_file_id"`
	Type         FileType `json:"type"`
	FileID       string   `json:"file_id"`
	DomainID     string   `json:"domain_id"`
	DriveID      string   `json:"drive_id"`
	FileName     string   `json:"file_name"`
	EncryptMode  string   `json:"encrypt_mode"`
}

type DefaultLogger

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

func (*DefaultLogger) Log

func (l *DefaultLogger) Log(ctx context.Context, level LogLevel, msg string, args ...interface{})

type DeleteFileReq

type DeleteFileReq struct {
	DriveID string `json:"drive_id"`
	FileID  string `json:"file_id"`
}

type DeleteFileResp

type DeleteFileResp struct {
	DomainID    string `json:"domain_id"`
	DriveID     string `json:"drive_id"`
	FileID      string `json:"file_id"`
	AsyncTaskID string `json:"async_task_id"`
}

type DownloadFileConflictType

type DownloadFileConflictType int
const (
	DownloadFileConflictTypeAutoRename DownloadFileConflictType = 0
	DownloadFileConflictTypeOverwrite  DownloadFileConflictType = 1
	DownloadFileConflictTypeError      DownloadFileConflictType = 2
)

type DownloadFileReq

type DownloadFileReq struct {
	DriveID         string                   `json:"drive_id"`
	FileID          string                   `json:"file_id"`
	Dist            string                   `json:"dist"`              // 如果此值不为空,则下载文件到这个位置
	DistDir         string                   `json:"dist_dir"`          // 如果此值不为空,则下载文件到 `DistDir`/<name> 位置
	ConflictType    DownloadFileConflictType `json:"conflict_type"`     // 如果目标文件已存在,处理方式:报错,覆盖,自动重命名,默认是自动重命名
	ShowProgressBar bool                     `json:"show_progress_bar"` // 展示下载进度条
}

type File

type File struct {
	DriveID         string    `json:"drive_id"`
	DomainID        string    `json:"domain_id"`
	FileID          string    `json:"file_id"`
	Name            string    `json:"name"`
	Type            string    `json:"type"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	Hidden          bool      `json:"hidden"`
	Starred         bool      `json:"starred"`
	Status          string    `json:"status"`
	UserMeta        string    `json:"user_meta,omitempty"`
	ParentFileID    string    `json:"parent_file_id"`
	EncryptMode     string    `json:"encrypt_mode"`
	ContentType     string    `json:"content_type,omitempty"`
	FileExtension   string    `json:"file_extension,omitempty"`
	MimeType        string    `json:"mime_type,omitempty"`
	MimeExtension   string    `json:"mime_extension,omitempty"`
	Size            int64     `json:"size,omitempty"`
	Crc64Hash       string    `json:"crc64_hash,omitempty"`
	ContentHash     string    `json:"content_hash,omitempty"`
	ContentHashName string    `json:"content_hash_name,omitempty"`
	DownloadURL     string    `json:"download_url,omitempty"`
	URL             string    `json:"url,omitempty"`
	Thumbnail       string    `json:"thumbnail,omitempty"`
	Category        string    `json:"category,omitempty"`
	PunishFlag      int       `json:"punish_flag,omitempty"`
}

type FileService

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

func (*FileService) CreateFolder

func (r *FileService) CreateFolder(ctx context.Context, request *CreateFolderReq) (*CreateFolderResp, error)

CreateFolder 创建文件夹

func (*FileService) DeleteFile

func (r *FileService) DeleteFile(ctx context.Context, request *DeleteFileReq) (*DeleteFileResp, error)

DeleteFile 删除文件

func (*FileService) DownloadFile

func (r *FileService) DownloadFile(ctx context.Context, request *DownloadFileReq) error

GetFile 获取文件信息

func (*FileService) DownloadFileStream added in v0.2.0

func (r *FileService) DownloadFileStream(ctx context.Context, driveID, fileID string) (io.ReadCloser, error)

DownloadFileStream 获取文件流

func (*FileService) GetFile

func (r *FileService) GetFile(ctx context.Context, request *GetFileReq) (*GetFileResp, error)

GetFile 获取文件信息

func (*FileService) GetFileDownloadURL

func (r *FileService) GetFileDownloadURL(ctx context.Context, request *GetFileDownloadURLReq) (*GetFileDownloadURLResp, error)

GetFile 获取文件信息

func (*FileService) GetFileList

func (r *FileService) GetFileList(ctx context.Context, request *GetFileListReq) (*GetFileListResp, error)

func (*FileService) GetFilePath

func (r *FileService) GetFilePath(ctx context.Context, request *GetFilePathReq) (*GetFilePathResp, error)

GetFilePath 重命名

func (*FileService) GetSBox

func (r *FileService) GetSBox(ctx context.Context) (*GetSBoxResp, error)

func (*FileService) MoveFile

func (r *FileService) MoveFile(ctx context.Context, request *MoveFileReq) (*MoveFileResp, error)

RenameFile 重命名

func (*FileService) RenameFile

func (r *FileService) RenameFile(ctx context.Context, request *RenameFileReq) (*RenameFileResp, error)

RenameFile 重命名

func (*FileService) SearchFile

func (r *FileService) SearchFile(ctx context.Context, request *SearchFileReq) (*GetFileListResp, error)

GetFile 获取文件信息

func (*FileService) UploadFile

func (r *FileService) UploadFile(ctx context.Context, request *UploadFileReq) (*UploadFileResp, error)

func (*FileService) UploadStream added in v0.2.0

func (r *FileService) UploadStream(ctx context.Context, driveID, parentID, name string, stream io.Reader, streamSize int64) (*UploadFileResp, error)

UploadStream 从流上传文件

type FileStore

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

func (*FileStore) Get

func (r *FileStore) Get(ctx context.Context, key string) (*Token, error)

func (*FileStore) Set

func (r *FileStore) Set(ctx context.Context, token *Token) error

type FileType added in v0.2.0

type FileType string // 文件类型枚举
const (
	FileTypeFolder FileType = "folder" // 文件夹
	FileTypeFile   FileType = "file"   // 文件
)

type GetFileDownloadURLReq

type GetFileDownloadURLReq struct {
	DriveID string `json:"drive_id"`
	FileID  string `json:"file_id"`
}

type GetFileDownloadURLResp

type GetFileDownloadURLResp struct {
	Method      string    `json:"method"`
	URL         string    `json:"url"`
	InternalURL string    `json:"internal_url"`
	CdnURL      string    `json:"cdn_url"`
	Expiration  time.Time `json:"expiration"`
	Size        int       `json:"size"`
	RateLimit   struct {
		PartSpeed int `json:"part_speed"`
		PartSize  int `json:"part_size"`
	} `json:"ratelimit"`
}

type GetFileListReq

type GetFileListReq struct {
	GetAll bool `json:"get_all"`

	ShareID               string `json:"share_id"` // drive_id 和 share_id 必选传其中一个
	DriveID               string `json:"drive_id"` // drive_id 和 share_id 必选传其中一个
	ParentFileID          string `json:"parent_file_id"`
	Marker                string `json:"marker"`
	Limit                 int    `json:"limit"`
	All                   bool   `json:"all"`
	URLExpireSec          int    `json:"url_expire_sec"`
	ImageThumbnailProcess string `json:"image_thumbnail_process"`
	ImageURLProcess       string `json:"image_url_process"`
	VideoThumbnailProcess string `json:"video_thumbnail_process"`
	Fields                string `json:"fields"`
	OrderBy               string `json:"order_by"`
	OrderDirection        string `json:"order_direction"`
}

type GetFileListResp

type GetFileListResp struct {
	Items      []*File `json:"items"`
	NextMarker string  `json:"next_marker"`
}

type GetFilePathReq

type GetFilePathReq struct {
	DriveID string `json:"drive_id"`
	FileID  string `json:"file_id"`
}

type GetFilePathResp

type GetFilePathResp struct {
	Items []*File `json:"items"`
}

type GetFileReq

type GetFileReq struct {
	DriveID string `json:"drive_id"`
	FileID  string `json:"file_id"`
}

type GetFileResp

type GetFileResp struct {
	File
	Trashed bool `json:"trashed"`
}

type GetSBoxResp

type GetSBoxResp struct {
	DriveID          string `json:"drive_id"`
	SboxUsedSize     int    `json:"sbox_used_size"`
	SboxRealUsedSize int    `json:"sbox_real_used_size"`
	SboxTotalSize    int64  `json:"sbox_total_size"`
	RecommendVip     string `json:"recommend_vip"`
	PinSetup         bool   `json:"pin_setup"`
	Locked           bool   `json:"locked"`
	InsuranceEnabled bool   `json:"insurance_enabled"`
}

type GetSelfUserResp

type GetSelfUserResp struct {
	DomainID                    string      `json:"domain_id"`
	UserID                      string      `json:"user_id"`
	Avatar                      string      `json:"avatar"`
	CreatedAt                   int64       `json:"created_at"`
	UpdatedAt                   int64       `json:"updated_at"`
	Email                       string      `json:"email"`
	NickName                    string      `json:"nick_name"`
	Phone                       string      `json:"phone"`
	Role                        string      `json:"role"`
	Status                      string      `json:"status"`
	UserName                    string      `json:"user_name"`
	Description                 string      `json:"description"`
	DefaultDriveID              string      `json:"default_drive_id"`
	DenyChangePasswordBySelf    bool        `json:"deny_change_password_by_self"`
	NeedChangePasswordNextLogin bool        `json:"need_change_password_next_login"`
	Permission                  interface{} `json:"permission"`
}

type GetShareByAnonymousReq

type GetShareByAnonymousReq struct {
	ShareID string `json:"share_id"`
}

type GetShareByAnonymousResp

type GetShareByAnonymousResp struct {
	CreatorID    string    `json:"creator_id"`
	CreatorName  string    `json:"creator_name"`
	CreatorPhone string    `json:"creator_phone"`
	Expiration   string    `json:"expiration"`
	UpdatedAt    time.Time `json:"updated_at"`
	Vip          string    `json:"vip"`
	Avatar       string    `json:"avatar"`
	ShareName    string    `json:"share_name"`
	FileCount    int       `json:"file_count"`
	FileInfos    []struct {
		Type     string `json:"type"`
		FileID   string `json:"file_id"`
		FileName string `json:"file_name"`
	} `json:"file_infos"`
}

type LogLevel

type LogLevel int
const (
	LogLevelTrace LogLevel = iota + 1 // 只有两个 log req 和 resp 的 文本内容
	LogLevelDebug
	LogLevelInfo
	LogLevelWarn
	LogLevelError
)

func (LogLevel) String

func (r LogLevel) String() string

type Logger

type Logger interface {
	Log(ctx context.Context, level LogLevel, msg string, args ...interface{})
}

func NewLoggerStdout

func NewLoggerStdout() Logger

type LoggerStdout

type LoggerStdout struct{}

func (*LoggerStdout) Log

func (l *LoggerStdout) Log(ctx context.Context, level LogLevel, msg string, args ...interface{})

type LoginByQrcodeReq added in v0.4.0

type LoginByQrcodeReq struct {
	SmallQrCode bool
}

type MoveFileReq

type MoveFileReq struct {
	DriveID        string `json:"drive_id"`
	FileID         string `json:"file_id"`
	ToDriveID      string `json:"to_drive_id"`
	ToParentFileID string `json:"to_parent_file_id"`
}

type MoveFileResp

type MoveFileResp struct {
	DomainID string `json:"domain_id"`
	DriveID  string `json:"drive_id"`
	FileID   string `json:"file_id"`
}

type RawRequestReq

type RawRequestReq struct {
	Scope  string
	API    string
	Method string
	URL    string
	Body   interface{}
	IsFile bool
	// contains filtered or unexported fields
}

type RefreshTokenReq

type RefreshTokenReq struct {
	RefreshToken string `json:"refresh_token"`
}

type RefreshTokenResp

type RefreshTokenResp struct {
	DefaultSboxDriveID string    `json:"default_sbox_drive_id"`
	Role               string    `json:"role"`
	DeviceID           string    `json:"device_id"`
	UserName           string    `json:"user_name"`
	NeedLink           bool      `json:"need_link"`
	ExpireTime         time.Time `json:"expire_time"`
	PinSetup           bool      `json:"pin_setup"`
	NeedRpVerify       bool      `json:"need_rp_verify"`
	Avatar             string    `json:"avatar"`
	UserData           struct {
		// DingDingRobotURL string `json:"DingDingRobotUrl"`
		// EncourageDesc    string `json:"EncourageDesc"`
		// FeedBackSwitch   bool   `json:"FeedBackSwitch"`
		// FollowingDesc    string `json:"FollowingDesc"`
		DingDingRobotURL string `json:"ding_ding_robot_url"`
		EncourageDesc    string `json:"encourage_desc"`
		FeedBackSwitch   bool   `json:"feed_back_switch"`
		FollowingDesc    string `json:"following_desc"`
	} `json:"user_data"`
	TokenType      string        `json:"token_type"`
	AccessToken    string        `json:"access_token"`
	DefaultDriveID string        `json:"default_drive_id"`
	RefreshToken   string        `json:"refresh_token"`
	IsFirstLogin   bool          `json:"is_first_login"`
	UserID         string        `json:"user_id"`
	NickName       string        `json:"nick_name"`
	ExistLink      []interface{} `json:"exist_link"`
	State          string        `json:"state"`
	ExpiresIn      int           `json:"expires_in"`
	Status         string        `json:"status"`
}

func (*RefreshTokenResp) Token

func (r *RefreshTokenResp) Token() *Token

type RenameFileReq

type RenameFileReq struct {
	DriveID       string `json:"drive_id"`
	FileID        string `json:"file_id"`
	Name          string `json:"name"`
	CheckNameMode string `json:"check_name_mode"`
}

type RenameFileResp

type RenameFileResp struct {
	DriveID          string `json:"drive_id"`
	SboxUsedSize     int    `json:"sbox_used_size"`
	SboxRealUsedSize int    `json:"sbox_real_used_size"`
	SboxTotalSize    int64  `json:"sbox_total_size"`
	RecommendVip     string `json:"recommend_vip"`
	PinSetup         bool   `json:"pin_setup"`
	Locked           bool   `json:"locked"`
	InsuranceEnabled bool   `json:"insurance_enabled"`
}

type Response

type Response struct {
	Method        string      // request method
	URL           string      // request url
	StatusCode    int         // http response status code
	Header        http.Header // http response header
	ContentLength int64       // http response content length
	Body          []byte
}

type SearchFileReq

type SearchFileReq struct {
	DriveID               string `json:"drive_id"`
	Limit                 int    `json:"limit"`
	Query                 string `json:"query"`
	ImageThumbnailProcess string `json:"image_thumbnail_process"`
	ImageURLProcess       string `json:"image_url_process"`
	VideoThumbnailProcess string `json:"video_thumbnail_process"`
	OrderBy               string `json:"order_by"`
}

type ShareLinkService

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

func (*ShareLinkService) GetShareByAnonymous

func (r *ShareLinkService) GetShareByAnonymous(ctx context.Context, request *GetShareByAnonymousReq) (*GetShareByAnonymousResp, error)

GetShareByAnonymous 通过分享 ID 获取分享内容

type Store

type Store interface {
	Get(ctx context.Context, key string) (*Token, error)
	Set(ctx context.Context, token *Token) error
}

Store 定义一个存储的接口,使用者可以按照自己的需求来实现

func NewFileStore

func NewFileStore(file string) Store

type Token

type Token struct {
	AccessToken  string    `json:"access_token"`
	ExpiredAt    time.Time `json:"expired_at"` // access-token 的过期时间,秒级
	RefreshToken string    `json:"refresh_token"`
}

type UploadFileReq

type UploadFileReq struct {
	DriveID         string
	ParentID        string
	FilePath        string
	ShowProgressBar bool // 展示上传进度条

}

type UploadFileResp

type UploadFileResp struct {
	DriveID            string    `json:"drive_id"`
	DomainID           string    `json:"domain_id"`
	FileID             string    `json:"file_id"`
	Name               string    `json:"name"`
	Type               string    `json:"type"`
	ContentType        string    `json:"content_type"` // application/oct-stream
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
	FileExtension      string    `json:"file_extension"`
	Hidden             bool      `json:"hidden"`
	Size               int       `json:"size"`
	Starred            bool      `json:"starred"`
	Status             string    `json:"status"` // available
	UploadID           string    `json:"upload_id"`
	ParentFileID       string    `json:"parent_file_id"`
	Crc64Hash          string    `json:"crc64_hash"`
	ContentHash        string    `json:"content_hash"`
	ContentHashName    string    `json:"content_hash_name"` // sha1
	Category           string    `json:"category"`
	EncryptMode        string    `json:"encrypt_mode"`
	ImageMediaMetadata struct {
		ImageQuality struct{} `json:"image_quality"`
	} `json:"image_media_metadata"`
	Location string `json:"location"`
}

Directories

Path Synopsis
get-share
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
list-files
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
login-by-qrcode
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
internal
helper_config
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
helper_tool
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
impl
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* * Copyright 2022 chyroc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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