file

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 18 Imported by: 0

README

文件管理

  1. 文件列表
  2. 文件信息
  3. 音视频在线播放地址
  4. 文件上传
  5. 文件下载

Documentation

Index

Constants

View Source
const (
	ListUri      = "/rest/2.0/xpan/file?method=list"
	MetasUri     = "/rest/2.0/xpan/multimedia?method=filemetas"
	StreamingUri = "/rest/2.0/xpan/file?method=streaming"
	ManagerUri   = "/rest/2.0/xpan/file?method=filemanager"
)
View Source
const (
	PreCreateUri        = "/rest/2.0/xpan/file?method=precreate"
	CreateUri           = "/rest/2.0/xpan/file?method=create"
	Superfile2UploadUri = "/rest/2.0/pcs/superfile2?method=upload"
)
View Source
const (
	PcsFileDownloadUri = "/rest/2.0/pcs/file?method=download"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateDirResponse

type CreateDirResponse struct {
	conf.CloudDiskResponseBase
	FsID           uint64 `json:"fs_id"`
	Path           string `json:"path"`
	Category       int    `json:"category"`
	ServerFileName string `json:"server_filename"`
	Size           int64  `json:"size"`
	Ctime          int    `json:"ctime"`
	Mtime          int    `json:"mtime"`
	IsDir          int    `json:"isdir"`
}

type Downloader

type Downloader struct {
	LocalFilePath string
	DownloadLink  string
	FsID          uint64
	Path          string
	AccessToken   string
	TotalPart     int
	Conf          conf.PanConfiguration
}

func NewDownloader

func NewDownloader(accessToken string, downloadLink string, localFilePath string) *Downloader

func NewDownloaderWithConfiguration

func NewDownloaderWithConfiguration(accessToken string, downloadLink string, localFilePath string, conf conf.PanConfiguration) *Downloader

func NewDownloaderWithFsID

func NewDownloaderWithFsID(accessToken string, fsID uint64, localFilePath string) *Downloader

func NewDownloaderWithFsIDAndConf

func NewDownloaderWithFsIDAndConf(accessToken string, fsID uint64, localFilePath string, conf conf.PanConfiguration) *Downloader

func NewDownloaderWithPath

func NewDownloaderWithPath(accessToken string, path string, localFilePath string) *Downloader

非开放平台公开接口,生产环境谨慎使用

func (*Downloader) Download

func (d *Downloader) Download() error

执行下载

type File

type File struct {
	AccessToken string
	Conf        conf.PanConfiguration
}

func NewFileClient

func NewFileClient(accessToken string) *File

func NewFileClientWithConfiguration

func NewFileClientWithConfiguration(accessToken string, configuration conf.PanConfiguration) *File

func (*File) CreateDir

func (f *File) CreateDir(path string) (CreateDirResponse, error)

func (*File) List

func (f *File) List(dir string, start, limit int) (ListResponse, error)

List 获取文件列表

func (*File) Metas

func (f *File) Metas(fsIDs []uint64) (MetasResponse, error)

Metas 通过FsID获取文件信息

func (*File) Streaming

func (f *File) Streaming(path string, transcodingType string) (string, error)

Streaming 获取音视频在线播放地址,转码类型有M3U8_AUTO_480=>视频ts、M3U8_FLV_264_480=>视频flv、M3U8_MP3_128=>音频mp3、M3U8_HLS_MP3_128=>音频ts

type IManagerRequestDTO

type IManagerRequestDTO interface {
	GetAsync() int
	GetFileListJsonStr() string
	GetFiles() any
	GetOndup() string
}

type ListResponse

type ListResponse struct {
	conf.CloudDiskResponseBase
	List []ListResponseListItem
}

type ListResponseListItem

type ListResponseListItem struct {
	FsID           uint64            `json:"fs_id"`
	Path           string            `json:"path"`
	ServerFileName string            `json:"server_filename"`
	Size           int64             `json:"size"`
	IsDir          int               `json:"isdir"`
	Category       int               `json:"category"`
	Md5            string            `json:"md5"`
	DirEmpty       string            `json:"dir_empty"`
	Thumbs         map[string]string `json:"thumbs"`
	LocalCtime     int               `json:"local_ctime"`
	LocalMtime     int               `json:"local_mtime"`
	ServerCtime    int               `json:"server_ctime"`
	ServerMtime    int               `json:"server_mtime"`
}

type LocalFileInfo

type LocalFileInfo struct {
	Md5  string
	Size int64
}

type Manager

type Manager struct {
	AccessToken string
	Conf        conf.PanConfiguration
}

func NewManagerClientWithConfiguration

func NewManagerClientWithConfiguration(accessToken string, configuration conf.PanConfiguration) *Manager

func (*Manager) Copy

func (*Manager) Delete

func (*Manager) Move

func (*Manager) Rename

type ManagerCopyRequestDTO

type ManagerCopyRequestDTO struct {
	Async int
	Files []ManagerCopyRequestFileItem
	Ondup string
}

func (*ManagerCopyRequestDTO) GetAsync

func (d *ManagerCopyRequestDTO) GetAsync() int

func (*ManagerCopyRequestDTO) GetFileListJsonStr

func (d *ManagerCopyRequestDTO) GetFileListJsonStr() string

func (*ManagerCopyRequestDTO) GetFiles

func (d *ManagerCopyRequestDTO) GetFiles() any

func (*ManagerCopyRequestDTO) GetOndup

func (d *ManagerCopyRequestDTO) GetOndup() string

type ManagerCopyRequestFileItem

type ManagerCopyRequestFileItem struct {
	Path    string `json:"path,omitempty"`
	Dest    string `json:"dest,omitempty"`
	NewName string `json:"newname,omitempty"`
	Ondup   string `json:"ondup,omitempty"`
}

type ManagerDeleteRequestDTO

type ManagerDeleteRequestDTO struct {
	Async int
	Files []string
	Ondup string
}

func (*ManagerDeleteRequestDTO) GetAsync

func (d *ManagerDeleteRequestDTO) GetAsync() int

func (*ManagerDeleteRequestDTO) GetFileListJsonStr

func (d *ManagerDeleteRequestDTO) GetFileListJsonStr() string

func (*ManagerDeleteRequestDTO) GetFiles

func (d *ManagerDeleteRequestDTO) GetFiles() any

func (*ManagerDeleteRequestDTO) GetOndup

func (d *ManagerDeleteRequestDTO) GetOndup() string

type ManagerRenameRequestDTO

type ManagerRenameRequestDTO struct {
	Async int
	Files []ManagerRenameRequestFileItem
	Ondup string
}

func (*ManagerRenameRequestDTO) GetAsync

func (d *ManagerRenameRequestDTO) GetAsync() int

func (*ManagerRenameRequestDTO) GetFileListJsonStr

func (d *ManagerRenameRequestDTO) GetFileListJsonStr() string

func (*ManagerRenameRequestDTO) GetFiles

func (d *ManagerRenameRequestDTO) GetFiles() any

func (*ManagerRenameRequestDTO) GetOndup

func (d *ManagerRenameRequestDTO) GetOndup() string

type ManagerRenameRequestFileItem

type ManagerRenameRequestFileItem struct {
	Path    string `json:"path,omitempty"`
	NewName string `json:"newname,omitempty"`
}

type ManagerResponse

type ManagerResponse struct {
	conf.CloudDiskResponseBase
	Info   []ManagerResponseInfoItem `json:"info,omitempty"`
	TaskID int64                     `json:"taskid,omitempty"`
}

type ManagerResponseInfoItem

type ManagerResponseInfoItem struct {
	Path  string `json:"path,omitempty"`
	Errno int    `json:"errno,omitempty"`
}

type MetasResponse

type MetasResponse struct {
	ErrorCode    int    `json:"errno"`
	ErrorMsg     string `json:"errmsg"`
	RequestID    int
	RequestIDStr string `json:"request_id"`
	List         []MetasResponseListItem
}

type MetasResponseListItem

type MetasResponseListItem struct {
	FsID        uint64            `json:"fs_id"`
	Path        string            `json:"path"`
	Category    int               `json:"category"`
	FileName    string            `json:"filename"`
	IsDir       int               `json:"isdir"`
	Size        int64             `json:"size"`
	Md5         string            `json:"md5"`
	DLink       string            `json:"dlink"`
	Thumbs      map[string]string `json:"thumbs"`
	ServerCtime int               `json:"server_ctime"`
	ServerMtime int               `json:"server_mtime"`
	DateTaken   int               `json:"date_taken"`
	Width       int               `json:"width"`
	Height      int               `json:"height"`
}

type PreCreateResponse

type PreCreateResponse struct {
	conf.CloudDiskResponseBase
	UploadID   string         `json:"uploadid"`
	Path       string         `json:"path"`
	ReturnType int            `json:"return_type"`
	BlockList  []int          `json:"block_list"`
	Info       UploadResponse `json:"info"`
}

type SuperFile2UploadResponse

type SuperFile2UploadResponse struct {
	conf.PcsResponseBase
	Md5      string `json:"md5"`
	UploadID string `json:"uploadid"`
	PartSeq  string `json:"partseq"` //pcsapi PHP版本返回的是int类型,Go版本返回的是string类型
}

type UploadResponse

type UploadResponse struct {
	conf.CloudDiskResponseBase
	Path  string `json:"path"`
	Size  int64  `json:"size"`
	Ctime int    `json:"ctime"`
	Mtime int    `json:"mtime"`
	Md5   string `json:"md5"`
	FsID  uint64 `json:"fs_id"`
	IsDir int    `json:"isdir"`
}

type Uploader

type Uploader struct {
	AccessToken   string
	Path          string //remote path
	LocalFilePath string
	Conf          conf.PanConfiguration
}

func NewUploader

func NewUploader(accessToken, path, localFilePath string) *Uploader

func NewUploaderWithConfiguration

func NewUploaderWithConfiguration(accessToken, path, localFilePath string, conf conf.PanConfiguration) *Uploader

func (*Uploader) Create

func (u *Uploader) Create(uploadID string, blockList []string) (UploadResponse, error)

file create

func (*Uploader) PreCreate

func (u *Uploader) PreCreate() (PreCreateResponse, error)

preCreate

func (*Uploader) SuperFile2Upload

func (u *Uploader) SuperFile2Upload(uploadID string, partSeq int, partByte []byte) (SuperFile2UploadResponse, error)

superfile2 upload

func (*Uploader) Upload

func (u *Uploader) Upload() (UploadResponse, error)

上传文件到网盘,包括预创建、分片上传、创建3个步骤

Jump to

Keyboard shortcuts

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