Documentation
¶
Index ¶
- Variables
- func NewServer(config Config, e *gin.Engine)
- type Code
- type Config
- type Context
- type EditProvider
- type Empty
- type Error
- type GetFileDownloadReply
- type GetFilePermissionReply
- type GetFileReply
- type GetWatermarkReply
- type Logger
- type NotifyArgs
- type NotifyContent
- type NotifyProvider
- type PreviewProvider
- type RenameFileArgs
- type Reply
- type Server
- type UpdateFilePhaseArgs
- type UserContext
- type UserProvider
- type UserReply
- type VersionProvider
- type WatermarkProvider
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPermissionDenied = &Error{code: 40003, statusCode: http.StatusForbidden, message: "permission denied"} ErrFileNotExists = &Error{code: 40004, statusCode: http.StatusForbidden, message: "file not exists"} ErrInvalidArguments = &Error{code: 40005, statusCode: http.StatusForbidden, message: "invalid arguments"} ErrSpaceFull = &Error{code: 40006, statusCode: http.StatusForbidden, message: "space full"} ErrFileNameConflict = &Error{code: 40008, statusCode: http.StatusForbidden, message: "filename conflict"} ErrFileVersionNotExists = &Error{code: 40009, statusCode: http.StatusForbidden, message: "file version not exists"} ErrUserNotExists = &Error{code: 40010, statusCode: http.StatusForbidden, message: "user not exists"} ErrInternalError = &Error{code: 50001, statusCode: http.StatusInternalServerError, message: "internal error"} )
枚举错误码
View Source
var Referer = "https://solution.wps.cn"
Functions ¶
Types ¶
type Config ¶
type Config struct { // 注册预览服务 PreviewProvider // 注册用户服务 UserProvider // 注册水印服务 WatermarkProvider // 注册编辑服务 EditProvider // 注册版本服务 VersionProvider // 路由前缀(上传用) Prefix string // 注册日志服务 Logger // 注册通知服务 NotifyProvider }
Config 配置
type Context ¶
type Context interface { context.Context // AppID 获取请求ID AppID() string // Token 获取请求Token Token() string // Query 获取请求参数 Query() url.Values // RequestID 获取请求ID RequestID() string }
Context 定义上下文接口
type EditProvider ¶
type EditProvider interface { // UpdateFile 更新文件 UpdateFile(ctx Context, fileID string, args *UpdateFilePhaseArgs) (*GetFileReply, error) // RenameFile 重命名文件 RenameFile(ctx Context, fileID string, args *RenameFileArgs) error }
EditProvider 定义编辑接口
type GetFileDownloadReply ¶
type GetFileDownloadReply struct { URL string `json:"url"` Headers map[string]string `json:"headers"` }
GetFileDownloadReply 获取文件下载地址返回信息
type GetFilePermissionReply ¶
type GetFilePermissionReply struct { Comment int `json:"comment"` Copy int `json:"copy"` Download int `json:"download"` History int `json:"history"` Print int `json:"print"` Read int `json:"read"` Rename int `json:"rename"` SaveAs int `json:"saveas"` Update int `json:"update"` UserId string `json:"user_id"` }
GetFilePermissionReply 获取文件权限返回信息
type GetFileReply ¶
type GetFileReply struct { CreateTime int64 `json:"create_time"` CreatorId string `json:"creator_id"` ID string `json:"id"` ModifierId string `json:"modifier_id"` ModifyTime int64 `json:"modify_time"` Name string `json:"name"` Size int64 `json:"size"` Version int32 `json:"version"` }
GetFileReply 获取文件返回信息
type GetWatermarkReply ¶
type GetWatermarkReply struct { Type int `json:"type"` Value string `json:"value"` FillStyle string `json:"fill_style"` Font string `json:"font"` Rotate float64 `json:"rotate"` Horizontal int `json:"horizontal"` Vertical int `json:"vertical"` }
GetWatermarkReply 获取水印返回信息
type NotifyArgs ¶
type NotifyArgs struct { FileId string `json:"file_id,omitempty"` Type string `json:"type,omitempty"` Content NotifyContent `json:"content,omitempty"` }
NotifyArgs 通知参数
type NotifyContent ¶
type NotifyContent struct { SessionId string `json:"session_id,omitempty"` InitVersion int `json:"init_version,omitempty"` Readonly bool `json:"readonly,omitempty"` UploadedVersion int `json:"uploaded_version,omitempty"` LastModifierId string `json:"last_modifier_id,omitempty"` ConnectionId string `json:"connection_id,omitempty"` UserId string `json:"user_id,omitempty"` Permission string `json:"permission,omitempty"` Print bool `json:"print,omitempty"` Format string `json:"format,omitempty"` }
NotifyContent 通知内容
type NotifyProvider ¶
type NotifyProvider interface { // OnNotify 触发通知 OnNotify(ctx Context, args *NotifyArgs) error }
NotifyProvider 定义通知接口
type PreviewProvider ¶
type PreviewProvider interface { // GetFile 获取文件信息 GetFile(ctx Context, fileID string) (*GetFileReply, error) // GetFileDownload 获取文件下载地址 GetFileDownload(ctx Context, fileID string) (*GetFileDownloadReply, error) // GetFilePermission 获取文件权限信息 GetFilePermission(ctx Context, fileID string) (*GetFilePermissionReply, error) }
PreviewProvider 定义预览接口
type RenameFileArgs ¶
type RenameFileArgs struct {
Name string `json:"name"`
}
RenameFileArgs 重命名文件参数
type Reply ¶
type Reply struct { Code Code `json:"code"` Message string `json:"message,omitempty"` Data any `json:"data"` }
Reply 返回参数结构体
type UpdateFilePhaseArgs ¶
type UpdateFilePhaseArgs struct { Name string Size int64 SHA1 string IsManual bool Content io.Reader }
UpdateFilePhaseArgs 更新文件阶段参数
type UserContext ¶ added in v1.0.3
UserContext 用户上下文
func (*UserContext) AppID ¶ added in v1.0.3
func (uc *UserContext) AppID() string
func (*UserContext) Query ¶ added in v1.0.3
func (uc *UserContext) Query() url.Values
func (*UserContext) RequestID ¶ added in v1.0.3
func (uc *UserContext) RequestID() string
func (*UserContext) Token ¶ added in v1.0.3
func (uc *UserContext) Token() string
type UserProvider ¶
type UserProvider interface { // GetUsers 获取用户信息 GetUsers(ctx Context, userIDs []string) ([]*UserReply, error) }
UserProvider 定义用户接口
type UserReply ¶
type UserReply struct { ID string `json:"id"` Name string `json:"name"` AvatarURL string `json:"avatar_url"` }
UserReply 用户信息
type VersionProvider ¶
type VersionProvider interface { // GetFileVersions 获取文件版本列表 GetFileVersions(ctx Context, fileID string, offset, limit int) ([]*GetFileReply, error) // GetFileVersion 获取文件指定版本信息 GetFileVersion(ctx Context, fileID string, version int32) (*GetFileReply, error) // GetFileVersionDownload 获取文件指定版本下载地址 GetFileVersionDownload(ctx Context, fileID string, version int32) (*GetFileDownloadReply, error) }
VersionProvider 定义版本接口
type WatermarkProvider ¶
type WatermarkProvider interface { // GetFileWatermark 获取文件水印信息 GetFileWatermark(ctx Context, fileID string) (*GetWatermarkReply, error) }
WatermarkProvider 定义水印接口
Click to show internal directories.
Click to hide internal directories.