Feat: preview doc file / Fix: chinese character encoding in attachment header

This commit is contained in:
HFO4
2019-12-16 13:24:09 +08:00
parent 9a942f8b48
commit e6d2a94809
4 changed files with 47 additions and 2 deletions

View File

@@ -158,6 +158,21 @@ func Preview(c *gin.Context) {
}
}
// GetDocPreview 获取DOC文件预览地址
func GetDocPreview(c *gin.Context) {
// 创建上下文
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var service explorer.SingleFileService
if err := c.ShouldBindUri(&service); err == nil {
res := service.CreateDocPreviewSession(ctx, c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
}
// CreateDownloadSession 创建文件下载会话
func CreateDownloadSession(c *gin.Context) {
// 创建上下文

View File

@@ -110,6 +110,8 @@ func InitRouter() *gin.Engine {
file.PUT("download/*path", controllers.CreateDownloadSession)
// 预览文件
file.GET("preview/*path", controllers.Preview)
// 取得Office文档预览地址
file.GET("doc/*path", controllers.GetDocPreview)
// 获取缩略图
file.GET("thumb/:id", controllers.Thumb)
// 取得文件外链