Documentation
¶
Index ¶
- Constants
- type Config
- type CorsCfg
- type FileDownloadStream
- type FileUploadStream
- type NoSniffFileInfo
- type PanClientProxy
- func (p *PanClientProxy) DownloadFilePart(sessionId, fileId string, offset int64, buffer []byte) (int, error)
- func (p *PanClientProxy) FileInfoByPath(pathStr string) (fileInfo *aliyunpan.FileEntity, error *apierror.ApiError)
- func (p *PanClientProxy) FileListGetAll(pathStr string) (aliyunpan.FileList, *apierror.ApiError)
- func (p *PanClientProxy) Mkdir(pathStr string, perm os.FileMode) error
- func (p *PanClientProxy) Move(oldpath, newpath string) error
- func (p *PanClientProxy) RemoveAll(pathStr string) error
- func (p *PanClientProxy) Rename(oldpath, newpath string) error
- func (p *PanClientProxy) UploadFileCache(userId, pathStr string) (*FileUploadStream, error)
- func (p *PanClientProxy) UploadFilePart(userId, pathStr string, offset int64, buffer []byte) (int, error)
- func (p *PanClientProxy) UploadFilePrepare(userId, pathStr string, fileSize int64, chunkSize int64) (*FileUploadStream, error)
- type Rule
- type User
- type WebDavDir
- func (d WebDavDir) Mkdir(ctx context.Context, name string, perm os.FileMode) error
- func (d WebDavDir) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error)
- func (d WebDavDir) RemoveAll(ctx context.Context, name string) error
- func (d WebDavDir) Rename(ctx context.Context, oldName, newName string) error
- func (d WebDavDir) Stat(ctx context.Context, name string) (os.FileInfo, error)
- type WebDavFile
- func (f *WebDavFile) Close() error
- func (f *WebDavFile) Read(p []byte) (int, error)
- func (f *WebDavFile) Readdir(count int) (fis []os.FileInfo, err error)
- func (f *WebDavFile) Seek(offset int64, whence int) (int64, error)
- func (f *WebDavFile) Stat() (os.FileInfo, error)
- func (f *WebDavFile) Write(p []byte) (int, error)
- type WebDavFileInfo
- func (f *WebDavFileInfo) ContentType(ctx context.Context) (contentType string, err error)
- func (f *WebDavFileInfo) IsDir() bool
- func (f *WebDavFileInfo) ModTime() time.Time
- func (f *WebDavFileInfo) Mode() os.FileMode
- func (f *WebDavFileInfo) Name() string
- func (f *WebDavFileInfo) Size() int64
- func (f *WebDavFileInfo) Sys() interface{}
- type WebdavConfig
- type WebdavUser
Constants ¶
View Source
const ( KeySessionId = "sessionId" KeyContentLength = "contentLength" KeyUserId = "userId" )
View Source
const CacheExpiredMinute = 60
CacheExpiredMinute 缓存过期分钟
View Source
const DefaultChunkSize = 10 * 1024 * 1024
DefaultChunkSize 默认上传的文件块大小,10MB
View Source
const FileDownloadUrlExpiredSeconds = 14400
FileDownloadUrlExpiredSeconds 文件下载URL过期时间
View Source
const FileUploadExpiredMinute = 1440 // 24小时
FileUploadExpiredMinute 文件上传数据流过期时间
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
*User
Auth bool
NoSniff bool
Cors CorsCfg
Users map[string]*User
LogFormat string
}
Config is the configuration of a WebDAV instance.
type CorsCfg ¶
type CorsCfg struct {
Enabled bool
Credentials bool
AllowedHeaders []string
AllowedHosts []string
AllowedMethods []string
ExposedHeaders []string
}
CorsCfg is the CORS config.
type FileDownloadStream ¶
type FileDownloadStream struct {
// contains filtered or unexported fields
}
type FileUploadStream ¶
type FileUploadStream struct {
// contains filtered or unexported fields
}
type NoSniffFileInfo ¶
NoSniffFileInfo wraps any generic FileInfo interface and bypasses mime type sniffing.
func (NoSniffFileInfo) ContentType ¶
func (w NoSniffFileInfo) ContentType(ctx context.Context) (contentType string, err error)
type PanClientProxy ¶
type PanClientProxy struct {
PanUser *config.PanUser
PanDriveId string
PanTransferUrlType int
// contains filtered or unexported fields
}
func (*PanClientProxy) DownloadFilePart ¶
func (p *PanClientProxy) DownloadFilePart(sessionId, fileId string, offset int64, buffer []byte) (int, error)
DownloadFilePart 下载文件指定数据片段
func (*PanClientProxy) FileInfoByPath ¶
func (p *PanClientProxy) FileInfoByPath(pathStr string) (fileInfo *aliyunpan.FileEntity, error *apierror.ApiError)
FileInfoByPath 通过文件路径获取网盘文件信息
func (*PanClientProxy) FileListGetAll ¶
FileListGetAll 获取文件路径下的所有子文件列表
func (*PanClientProxy) Mkdir ¶
func (p *PanClientProxy) Mkdir(pathStr string, perm os.FileMode) error
Mkdir 创建目录
func (*PanClientProxy) Move ¶
func (p *PanClientProxy) Move(oldpath, newpath string) error
Move 移动文件
func (*PanClientProxy) RemoveAll ¶
func (p *PanClientProxy) RemoveAll(pathStr string) error
RemoveAll 删除文件
func (*PanClientProxy) Rename ¶
func (p *PanClientProxy) Rename(oldpath, newpath string) error
Rename 重命名文件
func (*PanClientProxy) UploadFileCache ¶
func (p *PanClientProxy) UploadFileCache(userId, pathStr string) (*FileUploadStream, error)
func (*PanClientProxy) UploadFilePart ¶
func (p *PanClientProxy) UploadFilePart(userId, pathStr string, offset int64, buffer []byte) (int, error)
UploadFilePart 上传文件数据块
func (*PanClientProxy) UploadFilePrepare ¶
func (p *PanClientProxy) UploadFilePrepare(userId, pathStr string, fileSize int64, chunkSize int64) (*FileUploadStream, error)
UploadFilePrepare 创建文件上传
type User ¶
type User struct {
Username string
Password string
Scope string
Modify bool
Rules []*Rule
Handler *webdav.Handler
}
User contains the settings of each user.
type WebDavDir ¶
文件系统
type WebDavFile ¶
WebDavFile 文件实例
func (*WebDavFile) Close ¶
func (f *WebDavFile) Close() error
type WebDavFileInfo ¶
WebDavFileInfo 文件信息
func NewWebDavFileInfo ¶
func NewWebDavFileInfo(fileItem *aliyunpan.FileEntity) WebDavFileInfo
func (*WebDavFileInfo) ContentType ¶
func (f *WebDavFileInfo) ContentType(ctx context.Context) (contentType string, err error)
func (*WebDavFileInfo) IsDir ¶
func (f *WebDavFileInfo) IsDir() bool
func (*WebDavFileInfo) ModTime ¶
func (f *WebDavFileInfo) ModTime() time.Time
func (*WebDavFileInfo) Mode ¶
func (f *WebDavFileInfo) Mode() os.FileMode
func (*WebDavFileInfo) Name ¶
func (f *WebDavFileInfo) Name() string
func (*WebDavFileInfo) Size ¶
func (f *WebDavFileInfo) Size() int64
func (*WebDavFileInfo) Sys ¶
func (f *WebDavFileInfo) Sys() interface{}
type WebdavConfig ¶
type WebdavConfig struct {
// 指定Webdav使用哪个账号的云盘资源
PanUserId string `json:"panUserId"`
PanDriveId string `json:"panDriveId"`
PanUser *config.PanUser `json:"-"`
UploadChunkSize int `json:"uploadChunkSize"` // 上传文件分片数据块大小,该数值不能太小,建议大于等于512KB
TransferUrlType int `json:"transferUrlType"` // 上传/下载URL类别,1-默认,2-阿里云ECS
Address string `json:"address"`
Port int `json:"port"`
Prefix string `json:"prefix"`
Users []WebdavUser `json:"users"`
}
func (*WebdavConfig) StartServer ¶
func (w *WebdavConfig) StartServer()
type WebdavUser ¶
Click to show internal directories.
Click to hide internal directories.