Documentation ¶
Index ¶
- Constants
- Variables
- func NewDriver(policy *model.Policy) (driver.Handler, error)
- type APIError
- type BatchRequest
- type BatchRequests
- type BatchResponse
- type BatchResponses
- type Client
- func (client *Client) AccessToken() string
- func (client *Client) BatchDelete(ctx context.Context, dst []string) ([]string, error)
- func (client *Client) CreateUploadSession(ctx context.Context, dst string, opts ...Option) (string, error)
- func (client *Client) Delete(ctx context.Context, dst []string) ([]string, error)
- func (client *Client) DeleteUploadSession(ctx context.Context, uploadURL string) error
- func (client *Client) GetSiteIDByURL(ctx context.Context, siteUrl string) (string, error)
- func (client *Client) GetThumbURL(ctx context.Context, dst string, w, h uint) (string, error)
- func (client *Client) GetUploadSessionStatus(ctx context.Context, uploadURL string) (*UploadSessionResponse, error)
- func (client *Client) ListChildren(ctx context.Context, path string) ([]FileInfo, error)
- func (client *Client) Meta(ctx context.Context, id string, path string) (*FileInfo, error)
- func (client *Client) MonitorUpload(uploadURL, callbackKey, path string, size uint64, ttl int64)
- func (client *Client) OAuthURL(ctx context.Context, scope []string) string
- func (client *Client) ObtainToken(ctx context.Context, opts ...Option) (*Credential, error)
- func (client *Client) SimpleUpload(ctx context.Context, dst string, body io.Reader, size int64, opts ...Option) (*UploadResult, error)
- func (client *Client) UpdateCredential(ctx context.Context, isSlave bool) error
- func (client *Client) Upload(ctx context.Context, file fsctx.FileHeader) error
- func (client *Client) UploadChunk(ctx context.Context, uploadURL string, content io.Reader, ...) (*UploadSessionResponse, error)
- type Credential
- type Driver
- func (handler Driver) CancelToken(ctx context.Context, uploadSession *serializer.UploadSession) error
- func (handler Driver) Delete(ctx context.Context, files []string) ([]string, error)
- func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser, error)
- func (handler Driver) List(ctx context.Context, base string, recursive bool) ([]response.Object, error)
- func (handler Driver) Put(ctx context.Context, file fsctx.FileHeader) error
- func (handler Driver) Source(ctx context.Context, path string, ttl int64, isDownload bool, speed int) (string, error)
- func (handler Driver) Thumb(ctx context.Context, file *model.File) (*response.ContentResponse, error)
- func (handler Driver) Token(ctx context.Context, ttl int64, uploadSession *serializer.UploadSession, ...) (*serializer.UploadCredential, error)
- type Endpoints
- type FileInfo
- type ListResponse
- type OAuthError
- type Option
- type RespError
- type Site
- type ThumbResponse
- type UploadResult
- type UploadSessionResponse
Constants ¶
const ( // SmallFileSize 单文件上传接口最大尺寸 SmallFileSize uint64 = 4 * 1024 * 1024 // ChunkSize 服务端中转分片上传分片大小 ChunkSize uint64 = 10 * 1024 * 1024 // ListRetry 列取请求重试次数 ListRetry = 1 )
Variables ¶
var ( // ErrAuthEndpoint 无法解析授权端点地址 ErrAuthEndpoint = errors.New("failed to parse endpoint url") // ErrInvalidRefreshToken 上传策略无有效的RefreshToken ErrInvalidRefreshToken = errors.New("no valid refresh token in this policy") // ErrDeleteFile 无法删除文件 ErrDeleteFile = errors.New("cannot delete file") // ErrClientCanceled 客户端取消操作 ErrClientCanceled = errors.New("client canceled") // Desired thumb size not available ErrThumbSizeNotFound = errors.New("thumb size not found") )
Functions ¶
Types ¶
type BatchRequest ¶
type BatchRequest struct { ID string `json:"id"` Method string `json:"method"` URL string `json:"url"` Body interface{} `json:"body,omitempty"` Headers map[string]string `json:"headers,omitempty"` }
BatchRequest 批量操作单个请求
type BatchRequests ¶
type BatchRequests struct {
Requests []BatchRequest `json:"requests"`
}
BatchRequests 批量操作请求
type BatchResponse ¶
BatchResponse 批量操作单个响应
type BatchResponses ¶
type BatchResponses struct {
Responses []BatchResponse `json:"responses"`
}
BatchResponses 批量操作响应
type Client ¶
type Client struct { Endpoints *Endpoints Policy *model.Policy Credential *Credential ClientID string ClientSecret string Redirect string Request request.Client ClusterController cluster.Controller }
Client OneDrive客户端
func (*Client) AccessToken ¶
func (*Client) BatchDelete ¶
BatchDelete 并行删除给出的文件,返回删除失败的文件,及第一个遇到的错误。此方法将文件分为 20个一组,调用Delete并行删除 TODO 测试
func (*Client) CreateUploadSession ¶
func (client *Client) CreateUploadSession(ctx context.Context, dst string, opts ...Option) (string, error)
CreateUploadSession 创建分片上传会话
func (*Client) DeleteUploadSession ¶
DeleteUploadSession 删除上传会话
func (*Client) GetSiteIDByURL ¶
GetSiteIDByURL 通过 SharePoint 站点 URL 获取站点ID
func (*Client) GetThumbURL ¶
GetThumbURL 获取给定尺寸的缩略图URL
func (*Client) GetUploadSessionStatus ¶
func (client *Client) GetUploadSessionStatus(ctx context.Context, uploadURL string) (*UploadSessionResponse, error)
GetUploadSessionStatus 查询上传会话状态
func (*Client) ListChildren ¶
ListChildren 根据路径列取子对象
func (*Client) MonitorUpload ¶
MonitorUpload 监控客户端分片上传进度
func (*Client) ObtainToken ¶
ObtainToken 通过code或refresh_token兑换token
func (*Client) SimpleUpload ¶
func (client *Client) SimpleUpload(ctx context.Context, dst string, body io.Reader, size int64, opts ...Option) (*UploadResult, error)
SimpleUpload 上传小文件到dst
func (*Client) UpdateCredential ¶
UpdateCredential 更新凭证,并检查有效期
func (*Client) UploadChunk ¶
func (client *Client) UploadChunk(ctx context.Context, uploadURL string, content io.Reader, current *chunk.ChunkGroup) (*UploadSessionResponse, error)
UploadChunk 上传分片
type Credential ¶
type Credential struct { TokenType string `json:"token_type"` ExpiresIn int64 `json:"expires_in"` Scope string `json:"scope"` AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` UserID string `json:"user_id"` }
Credential 获取token时返回的凭证
type Driver ¶
Driver OneDrive 适配器
func (Driver) CancelToken ¶
func (handler Driver) CancelToken(ctx context.Context, uploadSession *serializer.UploadSession) error
取消上传凭证
func (Driver) List ¶
func (handler Driver) List(ctx context.Context, base string, recursive bool) ([]response.Object, error)
List 列取项目
func (Driver) Source ¶
func (handler Driver) Source( ctx context.Context, path string, ttl int64, isDownload bool, speed int, ) (string, error)
Source 获取外链URL
func (Driver) Thumb ¶
func (handler Driver) Thumb(ctx context.Context, file *model.File) (*response.ContentResponse, error)
Thumb 获取文件缩略图
func (Driver) Token ¶
func (handler Driver) Token(ctx context.Context, ttl int64, uploadSession *serializer.UploadSession, file fsctx.FileHeader) (*serializer.UploadCredential, error)
Token 获取上传会话URL
type Endpoints ¶
type Endpoints struct { OAuthURL string // OAuth认证的基URL OAuthEndpoints *oauthEndpoint EndpointURL string // 接口请求的基URL DriverResource string // 要使用的驱动器 // contains filtered or unexported fields }
Endpoints OneDrive客户端相关设置
type FileInfo ¶
type FileInfo struct { Name string `json:"name"` Size uint64 `json:"size"` Image imageInfo `json:"image"` ParentReference parentReference `json:"parentReference"` DownloadURL string `json:"@microsoft.graph.downloadUrl"` File *file `json:"file"` Folder *folder `json:"folder"` }
FileInfo 文件元信息
func (*FileInfo) GetSourcePath ¶
GetSourcePath 获取文件的绝对路径
type ListResponse ¶
ListResponse 列取子项目响应
type OAuthError ¶
type OAuthError struct { ErrorType string `json:"error"` ErrorDescription string `json:"error_description"` CorrelationID string `json:"correlation_id"` }
OAuthError OAuth相关接口的错误响应
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option 发送请求的额外设置
func WithConflictBehavior ¶
WithConflictBehavior 设置文件重名后的处理方式
type Site ¶
type Site struct { Description string `json:"description"` ID string `json:"id"` Name string `json:"name"` DisplayName string `json:"displayName"` WebUrl string `json:"webUrl"` }
Site SharePoint 站点信息
type ThumbResponse ¶
ThumbResponse 获取缩略图的响应
type UploadResult ¶
type UploadResult struct { ID string `json:"id"` Name string `json:"name"` Size uint64 `json:"size"` }
UploadResult 上传结果