file

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 17 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"
)
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"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader struct {
	LocalFilePath string
	DownloadLink  string
	FsID          uint64
	Path          string
	AccessToken   string
	TotalPart     int
}

func NewDownloader

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

func NewDownloaderWithFsID

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

func (*Downloader) Download

func (d *Downloader) Download() error

执行下载

type File

type File struct {
	AccessToken string
}

func NewFileClient

func NewFileClient(accessToken string) *File

func (*File) List

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

获取文件列表

func (*File) Metas

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

通过FsID获取文件信息

func (*File) Streaming

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

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

type ListResponse

type ListResponse struct {
	conf.CloudDiskResponseBase
	List []struct {
		FsID           uint64            `json:"fs_id"`
		Path           string            `json:"path"`
		ServerFileName string            `json:"server_filename"`
		Size           int               `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 ManagerResponse

type ManagerResponse struct {
	conf.CloudDiskResponseBase
	Info []struct {
		Path   string
		TaskID int
		Errno  int
	}
}

type MetasResponse

type MetasResponse struct {
	ErrorCode    int    `json:"errno"`
	ErrorMsg     string `json:"errmsg"`
	RequestID    int
	RequestIDStr string `json:"request_id"`
	List         []struct {
		FsID        uint64            `json:"fs_id"`
		Path        string            `json:"path"`
		Category    int               `json:"category"`
		FileName    string            `json:"filename"`
		IsDir       int               `json:"isdir"`
		Size        int               `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
}

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  int    `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
	LocalFilePath string
}

func NewUploader

func NewUploader(accessToken, path, localFilePath string) *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