aliyunpan

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultRootParentFileId 网盘根目录默认ID
	DefaultRootParentFileId string = "root"

	FileOrderByName      FileOrderBy = "name"
	FileOrderByCreatedAt FileOrderBy = "created_at"
	FileOrderByUpdatedAt FileOrderBy = "updated_at"
	FileOrderBySize      FileOrderBy = "size"

	// FileOrderDirectionDesc 降序
	FileOrderDirectionDesc FileOrderDirection = "DESC"
	// FileOrderDirectionAsc 升序
	FileOrderDirectionAsc FileOrderDirection = "ASC"

	// MaxRequestRetryCount 最大重试次数(应对请求频繁的错误限制)
	MaxRequestRetryCount = int64(10)

	// IllegalDownloadUrlPrefix 资源被屏蔽,提示资源非法链接
	IllegalDownloadUrlPrefix = "https://pds-system-file.oss-cn-beijing.aliyuncs.com/illegal"

	// DefaultChunkSize 默认分片大小,512KB
	DefaultChunkSize = int64(524288)

	// MaxPartNum 最大分片数量大小
	MaxPartNum = 10000

	// DefaultZeroSizeFileContentHash 0KB文件默认的SHA1哈希值
	DefaultZeroSizeFileContentHash = "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709"

	// ShellPatternCharacters 文件名\文件路径通配符字符串
	ShellPatternCharacters = "*?[]"

	// PathSeparator 路径分隔符
	PathSeparator = "/"
)
View Source
const (
	User        UserRole = "user"
	UnknownRole UserRole = "unknown"

	Enabled       UserStatus = "enable"
	UnknownStatus UserStatus = "unknown"
)

Variables

This section is empty.

Functions

func CalcProofCode added in v0.0.2

func CalcProofCode(accessToken string, reader rio.ReaderAtLen64, fileSize int64) string

CalcProofCode 计算文件上传防伪码

Types

type CompleteUploadFileParam

type CompleteUploadFileParam struct {
	DriveId  string `json:"drive_id"`
	FileId   string `json:"file_id"`
	UploadId string `json:"upload_id"`
}

CompleteUploadFileParam 提交上传文件传输完成参数

type CompleteUploadFileResult

type CompleteUploadFileResult struct {
	DriveId         string `json:"drive_id"`
	DomainId        string `json:"domain_id"`
	FileId          string `json:"file_id"`
	Name            string `json:"name"`
	Type            string `json:"type"`
	Size            int64  `json:"size"`
	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"`
	CreatedAt       string `json:"created_at"`
}

type CreateFileUploadParam

type CreateFileUploadParam struct {
	Name         string `json:"name"`
	DriveId      string `json:"drive_id"`
	ParentFileId string `json:"parent_file_id"`
	Size         int64  `json:"size"`
	// 上传文件分片参数,最大为 10000
	PartInfoList []FileUploadPartInfoParam `json:"part_info_list"`
	ContentHash  string                    `json:"content_hash"`
	// 默认为 sha1。可选:sha1,none
	ContentHashName string `json:"content_hash_name"`
	// 默认为 file
	Type string `json:"type"`
	// 默认为 auto_rename。可选:overwrite-覆盖网盘同名文件,auto_rename-自动重命名,refuse-无需检测
	CheckNameMode string `json:"check_name_mode"`

	ProofCode    string `json:"proof_code"`
	ProofVersion string `json:"proof_version"`

	// 分片大小
	// 不进行json序列化
	BlockSize int64 `json:"-"`
	// LocalCreatedAt 本地创建时间,只对文件有效,格式yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
	LocalCreatedAt string `json:"-"`
	// LocalModifiedAt 本地修改时间,只对文件有效,格式yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
	LocalModifiedAt string `json:"-"`
}

CreateFileUploadParam 创建上传文件参数

type CreateFileUploadResult

type CreateFileUploadResult struct {
	ParentFileId string                     `json:"parent_file_id"`
	PartInfoList []FileUploadPartInfoResult `json:"part_info_list"`
	UploadId     string                     `json:"upload_id"`
	// RapidUpload 是否秒传。true-已秒传,false-没有秒传,需要手动上传
	RapidUpload bool   `json:"rapid_upload"`
	Type        string `json:"type"`
	FileId      string `json:"file_id"`
	DomainId    string `json:"domain_id"`
	DriveId     string `json:"drive_id"`
	// FileName 保存在网盘的名称,因为网盘会自动重命名同名的文件
	FileName    string `json:"file_name"`
	EncryptMode string `json:"encrypt_mode"`
	Location    string `json:"location"`
}

CreateFileUploadResult 创建上传文件返回值

type DownloadFuncCallback

type DownloadFuncCallback func(httpMethod, fullUrl string, headers map[string]string) (resp *http.Response, err error)

type FileAsyncTaskResult added in v0.2.0

type FileAsyncTaskResult struct {
	// DriveId 网盘id
	DriveId string `json:"drive_id"`
	// FileId 文件ID
	FileId string `json:"file_id"`
	// AsyncTaskId 异步任务id。 如果返回为空字符串,表示直接移动成功。 如果返回非空字符串,表示需要经过异步处理。
	AsyncTaskId string `json:"async_task_id"`
}

FileAsyncTaskResult 文件异步操作返回值

type FileBatchActionParam

type FileBatchActionParam struct {
	// 网盘ID
	DriveId string `json:"drive_id"`
	// 文件ID
	FileId string `json:"file_id"`
}

FileBatchActionParam 文件批量操作参数

type FileBatchActionResult

type FileBatchActionResult struct {
	// 文件ID
	FileId string
	// 是否成功
	Success bool
}

FileBatchActionResult 文件批量操作返回值

type FileCopyParam added in v0.2.0

type FileCopyParam struct {
	// DriveId 网盘id
	DriveId string `json:"drive_id"`
	// FileId 文件ID
	FileId string `json:"file_id"`
	// ToParentFileId 目标目录ID、根目录为 root
	ToParentFileId string `json:"to_parent_file_id"`
}

FileCopyParam 文件复制参数

type FileDownloadRange

type FileDownloadRange struct {
	// 起始值,包含
	Offset int64
	// 结束值,包含
	End int64
}

FileDownloadRange 分片。0-100,101-200,201-300...

type FileEntity

type FileEntity struct {
	// 网盘ID
	DriveId string `json:"driveId"`
	// 域ID
	DomainId string `json:"domainId"`
	// FileId 文件ID
	FileId string `json:"fileId"`
	// FileName 文件名
	FileName string `json:"fileName"`
	// FileSize 文件大小
	FileSize int64 `json:"fileSize"`
	// 文件类别 folder / file
	FileType string `json:"fileType"`
	// 创建时间
	CreatedAt string `json:"createdAt"`
	// 最后修改时间
	UpdatedAt string `json:"updatedAt"`
	// 后缀名,例如:dmg
	FileExtension string `json:"fileExtension"`
	// 文件上传ID
	UploadId string `json:"uploadId"`
	// 父文件夹ID
	ParentFileId string `json:"parentFileId"`
	// 内容CRC64校验值,只有文件才会有
	Crc64Hash string `json:"crc64Hash"`
	// 内容Hash值,只有文件才会有
	ContentHash string `json:"contentHash"`
	// 内容Hash计算方法,只有文件才会有,默认为:sha1
	ContentHashName string `json:"contentHashName"`
	// FilePath 文件的完整路径
	Path string `json:"path"`
	// Category 文件分类,例如:image/video/doc/others
	Category string `json:"category"`
	// SyncFlag 同步盘标记,该文件夹是否是同步盘的文件
	SyncFlag bool `json:"syncFlag"`
	// SyncMeta 如果是同步盘的文件夹,则这里会记录该文件对应的同步机器和目录等信息
	SyncMeta string `json:"syncMeta"`
}

FileEntity 文件/文件夹信息

func NewFileEntityForRootDir

func NewFileEntityForRootDir() *FileEntity

NewFileEntityForRootDir 创建根目录"/"的默认文件信息

func (*FileEntity) IsDriveRootFolder

func (f *FileEntity) IsDriveRootFolder() bool

IsDriveRootFolder 是否是网盘根目录

func (*FileEntity) IsFile

func (f *FileEntity) IsFile() bool

IsFile 是否是文件

func (*FileEntity) IsFolder

func (f *FileEntity) IsFolder() bool

IsFolder 是否是文件夹

func (*FileEntity) String

func (f *FileEntity) String() string

文件展示信息

type FileGetPathResult added in v0.1.0

type FileGetPathResult struct {
	// 每一个item对应一个目录,最顶层的目录是root放在最后
	// 例如路径:/myphoto/photo2022/photo01,则对应顺序为item[0]={"photo01"}, item[1]={"photo2022"}, item[2]={"myphoto"}, item[3]={"root"}(只有root目录下的子文件夹才会有)
	Items []struct {
		Trashed      bool      `json:"trashed"`
		DriveId      string    `json:"drive_id"`
		FileId       string    `json:"file_id"`
		CreatedAt    time.Time `json:"created_at"`
		DomainId     string    `json:"domain_id"`
		EncryptMode  string    `json:"encrypt_mode"`
		Hidden       bool      `json:"hidden"`
		Name         string    `json:"name"`
		ParentFileId string    `json:"parent_file_id"`
		Starred      bool      `json:"starred"`
		Status       string    `json:"status"`
		Type         string    `json:"type"`
		UpdatedAt    string    `json:"updated_at"`
		UserMeta     string    `json:"user_meta"`
	} `json:"items"`
}

FileGetPathResult 文件路径详情信息结果

type FileList

type FileList []*FileEntity

FileList 文件列表

func (FileList) Count

func (fl FileList) Count() (fileN, directoryN int64)

Count 获取文件总数和目录总数

func (FileList) Item added in v0.1.2

func (fl FileList) Item(index int) *FileEntity

Item 文件项

func (FileList) ItemCount added in v0.1.2

func (fl FileList) ItemCount() int

ItemCount 文件数量

func (FileList) TotalSize

func (fl FileList) TotalSize() int64

TotalSize 获取目录下文件的总大小

type FileListParam

type FileListParam struct {
	OrderBy        FileOrderBy        `json:"order_by"`
	OrderDirection FileOrderDirection `json:"order_direction"`
	DriveId        string             `json:"drive_id"`
	ParentFileId   string             `json:"parent_file_id"`
	Limit          int                `json:"limit"`
	// Marker 下一页参数
	Marker string `json:"marker"`
}

FileListParam 文件列表参数

type FileListResult added in v0.0.2

type FileListResult struct {
	FileList FileList `json:"file_list"`
	// NextMarker 不为空代表还有下一页
	NextMarker string `json:"next_marker"`
}

FileListResult 文件列表返回值

type FileMoveParam

type FileMoveParam struct {
	// 源网盘ID
	DriveId string `json:"drive_id"`
	// 源文件ID
	FileId string `json:"file_id"`
	// 目标网盘ID
	ToDriveId string `json:"to_drive_id"`
	// 目标文件夹ID
	ToParentFileId string `json:"to_parent_file_id"`
}

FileMoveParam 文件移动参数

type FileMoveResult

type FileMoveResult struct {
	// 文件ID
	FileId string
	// 是否成功
	Success bool
}

FileMoveResult 文件移动返回值

type FileOrderBy added in v0.0.5

type FileOrderBy string

type FileOrderDirection added in v0.0.5

type FileOrderDirection string

type FileUploadCheckPreHashParam added in v0.2.0

type FileUploadCheckPreHashParam struct {
	// DriveId 网盘ID
	DriveId string `json:"drive_id"`
	// ParentFileId 父目录id,上传到根目录时填写 root
	ParentFileId string `json:"parent_file_id"`
	// Name 文件名称,按照 utf8 编码最长 1024 字节,不能以 / 结尾
	Name string `json:"name"`
	// Size 文件大小,单位为 byte。秒传必须
	Size int64 `json:"size"`
	// PreHash 针对大文件sha1计算非常耗时的情况, 可以先在读取文件的前1k的sha1, 如果前1k的sha1没有匹配的, 那么说明文件无法做秒传, 如果1ksha1有匹配再计算文件sha1进行秒传,这样有效边避免无效的sha1计算。
	PreHash string `json:"pre_hash"`
}

FileUploadCheckPreHashParam 文件PreHash检测参数

type FileUploadChunkData

type FileUploadChunkData struct {
	Reader    io.Reader
	ChunkSize int64
	// contains filtered or unexported fields
}

FileUploadChunkData 文件上传数据块

func (*FileUploadChunkData) Len

func (d *FileUploadChunkData) Len() int64

func (*FileUploadChunkData) Read

func (d *FileUploadChunkData) Read(p []byte) (n int, err error)

type FileUploadPartInfoParam

type FileUploadPartInfoParam struct {
	PartNumber int `json:"part_number"`
}

FileUploadPartInfoParam 上传文件分片参数。从1开始,最大为 10000

func GenerateFileUploadPartInfoList

func GenerateFileUploadPartInfoList(size int64) []FileUploadPartInfoParam

GenerateFileUploadPartInfoList 根据文件大小自动生成分片

func GenerateFileUploadPartInfoListWithChunkSize

func GenerateFileUploadPartInfoListWithChunkSize(size, chunkSize int64) []FileUploadPartInfoParam

GenerateFileUploadPartInfoListWithChunkSize 根据文件大小和指定的分片大小自动生成分片

type FileUploadPartInfoResult

type FileUploadPartInfoResult struct {
	PartNumber        int    `json:"part_number"`
	UploadURL         string `json:"upload_url"`
	InternalUploadURL string `json:"internal_upload_url"`
	ContentType       string `json:"content_type"`
}

type FileUploadRange

type FileUploadRange struct {
	// 起始值,包含
	Offset int64
	// 总上传长度
	Len int64
}

type GetFileDownloadUrlParam

type GetFileDownloadUrlParam struct {
	DriveId   string `json:"drive_id"`
	FileId    string `json:"file_id"`
	ExpireSec int    `json:"expire_sec"`
}

GetFileDownloadUrlParam 获取文件下载链接

type GetFileDownloadUrlResult

type GetFileDownloadUrlResult struct {
	Method      string `json:"method"`
	Url         string `json:"url"`
	InternalUrl string `json:"internal_url"`
	CdnUrl      string `json:"cdn_url"`
	Expiration  string `json:"expiration"`
	Size        int64  `json:"size"`
	Ratelimit   struct {
		PartSpeed int64 `json:"part_speed"`
		PartSize  int64 `json:"part_size"`
	} `json:"ratelimit"`
}

GetFileDownloadUrlResult 获取文件下载链接返回值

type GetUploadUrlParam

type GetUploadUrlParam struct {
	DriveId      string                    `json:"drive_id"`
	FileId       string                    `json:"file_id"`
	PartInfoList []FileUploadPartInfoParam `json:"part_info_list"`
	UploadId     string                    `json:"upload_id"`
}

GetUploadUrlParam 获取上传数据链接参数

type GetUploadUrlResult

type GetUploadUrlResult struct {
	DomainId     string                     `json:"domain_id"`
	DriveId      string                     `json:"drive_id"`
	FileId       string                     `json:"file_id"`
	PartInfoList []FileUploadPartInfoResult `json:"part_info_list"`
	UploadId     string                     `json:"upload_id"`
	CreateAt     string                     `json:"create_at"`
}

GetUploadUrlResult 获取上传数据链接返回值

type HandleFileDirectoryFunc

type HandleFileDirectoryFunc func(depth int, fdPath string, fd *FileEntity, apierr *apierror.ApiError) bool

HandleFileDirectoryFunc 处理文件或目录的元信息, 返回值控制是否退出递归

type MkdirResult

type MkdirResult struct {
	ParentFileId string `json:"parent_file_id"`
	Type         string `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"`
}

MkdirResult 创建文件夹返回值

type UploadFunc

type UploadFunc func(httpMethod, fullUrl string, headers map[string]string) (resp *http.Response, err error)

UploadFunc 上传文件处理函数

type UserInfo

type UserInfo struct {
	// DomainId 域ID
	DomainId string `json:"domainId"`
	// FileDriveId 备份(文件)网盘ID
	FileDriveId string `json:"fileDriveId"`
	// SafeBoxDriveId 保险箱网盘ID
	SafeBoxDriveId string `json:"safeBoxDriveId"`
	// AlbumDriveId 相册网盘ID
	AlbumDriveId string `json:"albumDriveId"`
	// ResourceDriveId 资源库网盘ID
	ResourceDriveId string `json:"resourceDriveId"`
	// 用户UID
	UserId string `json:"userId"`
	// UserName 用户名
	UserName string `json:"userName"`
	// CreatedAt 创建时间
	CreatedAt string `json:"createdAt"`
	// Email 邮箱
	Email string `json:"email"`
	// Phone 手机
	Phone string `json:"phone"`
	// Role 角色,默认是user
	Role UserRole `json:"role"`
	// Status 是否被禁用,enable / disable
	Status UserStatus `json:"status"`
	// Nickname 昵称,如果没有设置则为空
	Nickname string `json:"nickname"`
	// TotalSize 网盘空间总大小
	TotalSize uint64 `json:"totalSize"`
	// UsedSize 网盘已使用空间大小
	UsedSize uint64 `json:"usedSize"`
}

UserInfo 用户信息

type UserRole

type UserRole string

type UserStatus

type UserStatus string

type VideoGetPreviewPlayInfoParam added in v0.1.0

type VideoGetPreviewPlayInfoParam struct {
	DriveId string `json:"drive_id"`
	// FileId 视频文件ID
	FileId string `json:"file_id"`
}

VideoGetPreviewPlayInfoParam 视频信息参数

type VideoGetPreviewPlayInfoResult added in v0.1.0

type VideoGetPreviewPlayInfoResult struct {
	DomainId             string `json:"domain_id"`
	DriveId              string `json:"drive_id"`
	FileId               string `json:"file_id"`
	VideoPreviewPlayInfo struct {
		Category string `json:"category"`
		Meta     struct {
			Duration            float64 `json:"duration"`
			Width               int     `json:"width"`
			Height              int     `json:"height"`
			LiveTranscodingMeta struct {
				TsSegment    int `json:"ts_segment"`
				TsTotalCount int `json:"ts_total_count"`
				TsPreCount   int `json:"ts_pre_count"`
			} `json:"live_transcoding_meta"`
		} `json:"meta"`
		LiveTranscodingTaskList []struct {
			TemplateId     string `json:"template_id"`
			TemplateName   string `json:"template_name"`
			TemplateWidth  int    `json:"template_width"`
			TemplateHeight int    `json:"template_height"`
			Status         string `json:"status"`
			Stage          string `json:"stage"`
			URL            string `json:"url"`
		} `json:"live_transcoding_task_list"`
	} `json:"video_preview_play_info"`
}

VideoGetPreviewPlayInfoResult 视频信息返回值

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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