file

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(dlink string, rangeBytes ...DownloadRange) (io.ReadCloser, error)

执行下载

func DownloadUrl

func DownloadUrl(dlink string) string

获取下载链接

Types

type AsyncMode

type AsyncMode int
const (
	Sync  AsyncMode = 0 // 同步
	Auto  AsyncMode = 1 // 自适应
	Async AsyncMode = 2 // 异步
)

type CreateReq

type CreateReq struct {
	Path       string                `body:"path"`        // 上传后使用的文件绝对路径,需要urlencode,需要与预上传precreate接口中的path保持一致
	Size       types.SizeB           `body:"size"`        // 文件或目录的大小,必须要和文件真实大小保持一致,需要与预上传precreate接口中的size保持一致
	IsDir      types.BoolInt         `body:"isdir"`       // 是否目录,0 文件、1 目录,需要与预上传precreate接口中的isdir保持一致
	BlockList  []string              `body:"block_list"`  // 文件各分片md5数组的json串 需要与预上传precreate接口中的block_list保持一致,同时对应分片上传superfile2接口返回的md5,且要按照序号顺序排列,组成md5数组的json串。
	UploadId   string                `body:"uploadid"`    // 预上传precreate接口下发的uploadid
	RType      types.FileCreateRType `body:"rtype"`       // 文件命名策略
	LocalCtime types.Time            `body:"local_ctime"` // 客户端创建时间(精确到秒),默认为当前时间戳
	LocalMtime types.Time            `body:"local_mtime"` // 客户端修改时间(精确到秒),默认为当前时间戳
	ZipQuality int                   `body:"zip_quality"` // 图片压缩程度,有效值50、70、100(带此参数时,zip_sign 参数需要一并带上)
	ZipSign    string                `body:"zip_sign"`    // 未压缩原始图片文件真实md5(带此参数时,zip_quality 参数需要一并带上)
	IsRevision types.BoolInt         `body:"is_revision"` // 是否需要多版本支持
	Mode       types.CreateMode      `body:"mode"`        // 上传方式
	ExifInfo   *ExifInfo             `body:"exif_info"`   // orientation、width、height、recovery为必传字段,其他字段如果没有可以不传
}

type CreateRes

type CreateRes struct {
	FsId           uint64             `json:"fs_id"`           // 文件在云端的唯一标识ID
	Md5            string             `json:"md5"`             // 文件的MD5,只有提交文件时才返回,提交目录时没有该值
	ServerFilename string             `json:"server_filename"` // 文件名
	Category       types.FileCategory `json:"category"`        // 分类类型
	Path           string             `json:"path"`            // 上传后使用的文件绝对路径
	Size           types.SizeB        `json:"size"`            // 文件大小,单位B
	Ctime          types.Time         `json:"ctime"`           // 文件创建时间
	Mtime          types.Time         `json:"mtime"`           // 文件修改时间
	IsDir          types.BoolInt      `json:"isdir"`           // 是否目录
}

func Create

func Create(req *CreateReq) (*CreateRes, error)

创建文件 合块

func Mkdir

func Mkdir(path string) (*CreateRes, error)

type DownloadRange

type DownloadRange struct {
	Start types.SizeB
	End   types.SizeB
}

type ExifInfo

type ExifInfo struct {
	Height            int    `json:"height"`
	DateTimeOriginal  string `json:"date_time_original"`
	Model             string `json:"model"`
	Width             int    `json:"width"`
	DateTimeDigitized string `json:"date_time_digitized"`
	DateTime          string `json:"date_time"`
	Orientation       int    `json:"orientation"`
	Recovery          int    `json:"recovery"`
}

type FileCopyAndMoveItem

type FileCopyAndMoveItem struct {
	Path    string `json:"path"`    // 操作文件路径
	Dest    string `json:"dest"`    // 目标的目录
	Newname string `json:"newname"` // 操作文件的新名称
}

type FileDeleteItem

type FileDeleteItem string

type FileOp

type FileOp = string
const (
	Move   FileOp = "move"
	Copy   FileOp = "copy"
	Rename FileOp = "rename"
	Delete FileOp = "delete"
)

type FileRenameItem

type FileRenameItem struct {
	Path    string `json:"path"`    // 操作文件路径
	Newname string `json:"newname"` // 操作文件的新名称
}

type FilemanagerItem

type FilemanagerItem struct {
	Path  string `json:"path"`  // 文件路径
	Errno int    `json:"errno"` // 是否发生错误
}

type FilemanagerReq

type FilemanagerReq[FileOpItem FileCopyAndMoveItem | FileRenameItem | FileDeleteItem] struct {
	Opera    FileOp          `query:"opera"`   // move/copy/rename/delete
	Async    AsyncMode       `query:"async"`   // 异步模式
	Filelist []FileOpItem    `body:"filelist"` // 操作文件列表
	Ondup    types.OndupMode `body:"ondup"`    // 遇到重复文件的处理策略
}

type FilemanagerRes

type FilemanagerRes struct {
	TaskId uint64             `json:"taskid"` // 异步任务ID
	List   []*FilemanagerItem `json:"list"`   // 同步任务响应的操作结果
}

func Filemanager

func Filemanager[FileOpItem FileCopyAndMoveItem | FileRenameItem | FileDeleteItem](req *FilemanagerReq[FileOpItem]) (*FilemanagerRes, error)

复制 删除 重命名 移动

type FilemetasItem

type FilemetasItem struct {
	FsId        uint64             `json:"fs_id"`        // 文件在云端的唯一标识ID
	Category    types.FileCategory `json:"category"`     //	文件类型,1 视频、2 音频、3 图片、4 文档、5 应用、6 其他、7 种子
	Dlink       string             `json:"dlink"`        // 文件下载地址,参考下载文档进行下载操作。注意unicode解码处理。
	Filename    string             `json:"filename"`     // 文件名
	IsDir       types.BoolInt      `json:"isdir"`        //	是否为目录,0 文件、1 目录
	ServerMtime types.Time         `json:"server_mtime"` //	文件在服务器修改时间
	ServerCtime types.Time         `json:"server_ctime"` //	文件在服务器创建时间
	LocalMtime  *types.Time        `json:"local_mtime"`  // 文件在客户端修改时间
	LocalCtime  *types.Time        `json:"local_ctime"`  // 文件在客户端创建时间
	Size        types.SizeB        `json:"size"`         //	文件大小,单位B
	PhotoFileInfo
	VideoFileInfo
}

type FilemetasReq

type FilemetasReq struct {
	FsIds     []uint64      `query:"fsids"`      // 文件id数组,数组中元素是uint64类型,数组大小上限是:100
	Dlink     types.BoolInt `query:"dlink"`      // 是否需要下载地址 获取到dlink后,参考下载文档进行下载操作
	Path      string        `query:"path"`       // 查询共享目录或专属空间内文件时需要。含义并非待查询文件的路径,而是查询特定目录下文件的开关参数。共享目录格式: /uk-fsid 其中uk为共享目录创建者id, fsid对应共享目录的fsid 专属空间格式:/_pcs_.appdata/xpan/。此参数生效时,不会返回正常目录下文件的信息。
	Thumb     types.BoolInt `query:"thumb"`      // 是否需要缩略图地址
	Extra     types.BoolInt `query:"extra"`      //	图片是否需要拍摄时间、原图分辨率等其他信息
	Needmedia types.BoolInt `query:"needmedia"`  // 视频是否需要展示时长信息,返回 duration 信息时间单位为秒 (s),转换为向上取整。
	Detail    types.BoolInt `query:"detail"`     // 视频是否需要展示长,宽等信息。返回信息在media_info字段内
	DeviceId  string        `query:"device_id"`  // 设备ID,硬件设备必传
	FromApaas types.BoolInt `query:"from_apaas"` // 为下载地址(dlink)附加极速流量权益。用户通过此dlink产生下载行为时,消耗等同于文件大小的极速流量权益。此权益为付费权益,否则此参数无效。
}

type FilemetasRes

type FilemetasRes struct {
	Names any              `json:"names"` //如果查询共享目录,该字段为共享目录文件上传者的uk和账户名称
	List  []*FilemetasItem `json:"list"`
}

func Filemetas

func Filemetas(req *FilemetasReq) (*FilemetasRes, error)

type ListAllReq

type ListAllReq struct {
	Path      string          `query:"path" default:"/"`      // 需要list的目录,以/开头的绝对路径, 默认为/
	Recursion types.BoolInt   `query:"recursion" default:"0"` // 递归获取全部子目录下文件列表,默认为不需要
	Order     types.ListOrder `query:"name" default:"name"`   // 排序字段:默认为name; time按修改时间排序;name表示按文件名称排序 size表示按文件大小排序。
	Desc      types.BoolInt   `query:"desc"`                  // 默认为升序 设置为true实现降序 (注:排序的对象是当前目录下所有文件,不是当前分页下的文件)
	Start     int             `query:"start" default:"0"`     // 起始位置,从0开始
	Limit     int             `query:"limit" default:"1000"`  // 查询数目,默认为1000,建议最大不超过1000
	Ctime     types.Time      `query:"ctime"`                 // 文件上传时间,设置此参数,表示只返回上传时间大于ctime的文件
	Mtime     types.Time      `query:"mtime"`                 // 文件修改时间,设置此参数,表示只返回修改时间大于mtime的文件
	Web       types.BoolInt   `query:"web"`                   // 返回dir_empty属性和缩略图数据;不传该参数,则不返回缩略图地址
	DeviceId  string          `query:"device_id"`             // 设备ID,硬件设备必传
}

type ListItem

type ListItem struct {
	FsId        uint64             `json:"fs_id"`           // 文件在云端的唯一标识ID
	Path        string             `json:"path"`            // 文件的绝对路径
	Name        string             `json:"server_filename"` //	文件名称
	Size        types.SizeB        `json:"size"`            //	文件大小,单位B
	ServerMtime types.Time         `json:"server_mtime"`    //	文件在服务器修改时间
	ServerCtime types.Time         `json:"server_ctime"`    //	文件在服务器创建时间
	LocalMtime  types.Time         `json:"local_mtime"`     //	文件在客户端修改时间
	LocalCtime  types.Time         `json:"local_ctime"`     //	文件在客户端创建时间
	IsDir       types.BoolInt      `json:"isdir"`           //	是否为目录,0 文件、1 目录
	Category    types.FileCategory `json:"category"`        //	文件类型,1 视频、2 音频、3 图片、4 文档、5 应用、6 其他、7 种子
	ServerMd5   string             `json:"md5"`             //	云端哈希(非文件真实MD5),只有是文件类型时,该字段才存在
	DirEmpty    types.BoolInt      `json:"dir_empty"`       //	该目录是否存在子目录,只有请求参数web=1且该条目为目录时,该字段才存在, 0为存在, 1为不存在
	Thumbs      *Thumbs            `json:"thumbs"`          //	只有请求参数web=1且该条目分类为图片时,该字段才存在,包含三个尺寸的缩略图URL;不传web参数,则不返回缩略图地址
}

func List

func List(req *ListReq) ([]*ListItem, error)

type ListReq

type ListReq struct {
	Dir       string          `query:"dir" default:"/"`      //	需要list的目录,以/开头的绝对路径, 默认为/
	Order     types.ListOrder `query:"name" default:"name"`  // 排序字段:默认为name; time按修改时间排序;name表示按文件名称排序 size表示按文件大小排序。
	Desc      types.BoolInt   `query:"desc"`                 // 默认为升序 设置为true实现降序 (注:排序的对象是当前目录下所有文件,不是当前分页下的文件)
	Start     int             `query:"start" default:"0"`    //	起始位置,从0开始
	Limit     int             `query:"limit" default:"1000"` // 查询数目,默认为1000,建议最大不超过1000
	Web       types.BoolInt   `query:"web"`                  // 返回dir_empty属性和缩略图数据;不传该参数,则不返回缩略图地址
	Folder    types.BoolInt   `query:"folder"`               //	是否只返回文件夹且属性只返回path字段
	Showempty types.BoolInt   `query:"showempty"`            // 是否返回dir_empty属性,0 不返回,1 返回
}

type ListRes

type ListRes struct {
	HasMore types.BoolInt `json:"has_more"` //	是否还有下一页,0表示无,1表示有
	Cursor  int           `json:"cursor"`   // 当还有下一页时,为下一次查询的起点
	List    []*ListItem   `json:"list"`     // 文件列表
}

func ListAll

func ListAll(req *ListAllReq) (*ListRes, error)

type LocateUploadReq

type LocateUploadReq struct {
	AppId         int    `query:"appid" default:"250528"`       // 应用ID,本接口固定为250528
	UploadVersion string `query:"upload_version" default:"2.0"` // 版本号,本接口固定为2.0
	Path          string `query:"path"`                         // 上传后使用的文件绝对路径,需要urlencode
	UploadId      string `query:"uploadid"`                     // 上传ID
}

type LocateUploadRes

type LocateUploadRes struct {
	BakServer   []Server   `json:"bak_server"`
	BakServers  []Server   `json:"bak_servers"`
	ClientIp    string     `json:"client_ip"`
	ExpireSec   int        `json:"expire"`
	Host        string     `json:"host"`
	Newno       string     `json:"newno"`
	QuicServer  []Server   `json:"quic_server"`
	QuicServers []Server   `json:"quic_servers"`
	Server      []Server   `json:"server"`
	ServerTime  types.Time `json:"server_time"`
	Servers     []Server   `json:"servers"`
	Sl          int        `json:"sl"`
}

上传文件数据时,需要先通过此接口获取上传域名。可使用返回结果servers字段中的 https 协议的任意一个域名

func LocateUpload

func LocateUpload(req *LocateUploadReq) (*LocateUploadRes, error)

type MediaInfo

type MediaInfo struct {
	Channels   int     `json:"channels"`
	Duration   int     `json:"duration"`
	DurationMs int     `json:"duration_ms"`
	ExtraInfo  string  `json:"extra_info"`
	FileSize   string  `json:"file_size"`
	FrameRate  float64 `json:"frame_rate"`
	Height     int     `json:"height"`
	MetaInfo   string  `json:"meta_info"`
	Resolution string  `json:"resolution"`
	Rotate     int     `json:"rotate"`
	SampleRate int     `json:"sample_rate"`
	UseSegment int     `json:"use_segment"`
	Width      int     `json:"width"`
}

type PhotoFileInfo

type PhotoFileInfo struct {
	Thumbs      *Thumbs    `json:"thumbs"`      // 图片缩略图 包含4个尺寸
	Height      *int       `json:"height"`      // 图片高度
	Width       *int       `json:"width"`       // 图片宽度
	DateTaken   types.Time `json:"date_taken"`  // 图片拍摄时间
	Orientation *string    `json:"orientation"` // 图片旋转方向信息
}

type PreCreateReq

type PreCreateReq struct {
	Path      string        `body:"path"`                 // 上传后使用的文件绝对路径
	Size      types.SizeB   `body:"size"`                 // 文件和目录两种情况:上传文件时,表示文件的大小,单位B;上传目录时,表示目录的大小,目录的话大小默认为0
	IsDir     types.BoolInt `body:"isdir"`                // 是否为目录,0 文件,1 目录
	BlockList []string      `body:"block_list"`           // 文件各分片MD5数组的json串。block_list的含义如下,如果上传的文件小于4MB,其md5值(32位小写)即为block_list字符串数组的唯一元素;如果上传的文件大于4MB,需要将上传的文件按照4MB大小在本地切分成分片,不足4MB的分片自动成为最后一个分片,所有分片的md5值(32位小写)组成的字符串数组即为block_list。
	AutoInit  int           `body:"autoinit" default:"1"` // 固定值1

	// 1 表示当path冲突时,进行重命名
	// 2 表示当path冲突且block_list不同时,进行重命名
	// 3 当云端存在同名文件时,对该文件进行覆盖
	RType types.FileCreateRType `body:"rtype"` // 文件命名策略。

	UploadId   string `body:"uploadid"`    // 上传ID
	ContentMd5 string `body:"content-md5"` // 文件MD5,32位小写
	SliceMd5   string `body:"slice-md5"`   // 文件校验段的MD5,32位小写,校验段对应文件前256KB
	LocalCtime string `body:"local_ctime"` // 客户端创建时间, 默认为当前时间戳
	LocalMtime string `body:"local_mtime"` // 客户端修改时间,默认为当前时间戳
}

type PreCreateRes

type PreCreateRes struct {
	Path       string `json:"path"`        // 文件的绝对路径
	UploadId   string `json:"uploadid"`    // 上传唯一ID标识此上传任务
	ReturnType int    `json:"return_type"` // 返回类型,系统内部状态字段
	BlockList  []int  `json:"block_list"`  // 需要上传的分片序号列表,索引从0开始
}

func PreCreate

func PreCreate(req *PreCreateReq) (*PreCreateRes, error)

type SearchReq

type SearchReq struct {
	Key       string             `query:"key"`                   // 搜索关键字,最大30字符(UTF8格式)
	Dir       string             `query:"dir" default:"/"`       // 搜索目录,默认根目录
	Category  types.FileCategory `query:"category"`              //	文件类型,1 视频、2 音频、3 图片、4 文档、5 应用、6 其他、7 种子
	Recursion types.BoolInt      `query:"recursion" default:"0"` // 递归获取全部子目录下文件列表,默认为不需要
	Web       types.BoolInt      `query:"web"`                   // 返回dir_empty属性和缩略图数据;不传该参数,则不返回缩略图地址
	DeviceId  string             `query:"device_id"`             // 设备ID,硬件设备必传
}

NOTE:分页???

type SearchRes

type SearchRes struct {
	HasMore types.BoolInt `json:"has_more"` // 是否还有下一页,0表示无,1表示有
	List    []*ListItem   `json:"list"`     // 文件列表
}
func Search(req *SearchReq) (*SearchRes, error)

type Server

type Server struct {
	Server string `json:"server"`
}

type Thumbs

type Thumbs struct {
	Icon string `json:"icon"`
	Url1 string `json:"url1"`
	Url2 string `json:"url2"`
	Url3 string `json:"url3"`
}

type UploadChunkReq

type UploadChunkReq struct {
	Type     string    `query:"type" default:"tmpfile"` // 固定值 tmpfile
	Path     string    `query:"path"`                   // 上传后使用的文件绝对路径,需要与上一个阶段预上传precreate接口中的path保持一致
	UploadId string    `query:"uploadid"`               // 上一个阶段预上传precreate接口下发的uploadid
	PartSeq  int       `query:"partseq"`                // 文件分片的位置序号,从0开始,参考上一个阶段预上传precreate接口返回的block_list
	File     io.Reader `file:"file"`                    // 上传的文件内容
}

type UploadChunkRes

type UploadChunkRes struct {
	Md5 string `json:"md5"` // 云端的md5 不是文件本身的
}

func UploadChunk

func UploadChunk(req *UploadChunkReq, uploadHost string) (*UploadChunkRes, error)

上传主机名通过locate_upload接口获取

type UploadReq

type UploadReq struct {
	Path  string          `query:"path"`  // 上传的文件绝对路径
	Ondup types.OndupMode `query:"ondup"` // 遇到重复文件的处理策略
	File  io.Reader       `file:"file"`   // 上传的文件内容
}

type UploadRes

type UploadRes struct {
	Path  string      `json:"path"`  // 文件的绝对路径
	Size  types.SizeB `json:"size"`  // 文件大小,单位B
	Ctime types.Time  `json:"ctime"` // 文件创建时间
	Mtime types.Time  `json:"mtime"` // 文件修改时间
	Md5   string      `json:"md5"`   // 文件的MD5,只有提交文件时才返回,提交目录时没有该值
	FsId  uint64      `json:"fs_id"` // 文件在云端的唯一标识ID
}

func Upload

func Upload(req *UploadReq, uploadHost string) (*UploadRes, error)

单步上传 上传文件大小上限为2GB 此接口可能有一定限制,推荐使用主流接口分片上传

type VideoFileInfo

type VideoFileInfo struct {
	MediaInfo *MediaInfo `json:"media_info"` // 视频信息
}

Jump to

Keyboard shortcuts

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