|
|
|
@ -46,7 +46,7 @@ func PreviewShare(c *gin.Context) {
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
var service share.SingleFileService
|
|
|
|
|
if err := c.ShouldBindUri(&service); err == nil {
|
|
|
|
|
if err := c.ShouldBindQuery(&service); err == nil {
|
|
|
|
|
res := service.PreviewContent(ctx, c, false)
|
|
|
|
|
// 是否需要重定向
|
|
|
|
|
if res.Code == -301 {
|
|
|
|
@ -61,3 +61,32 @@ func PreviewShare(c *gin.Context) {
|
|
|
|
|
c.JSON(200, ErrorResponse(err))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PreviewShareText 预览文本文件
|
|
|
|
|
func PreviewShareText(c *gin.Context) {
|
|
|
|
|
// 创建上下文
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
var service share.SingleFileService
|
|
|
|
|
if err := c.ShouldBindQuery(&service); err == nil {
|
|
|
|
|
res := service.PreviewContent(ctx, c, true)
|
|
|
|
|
// 是否有错误发生
|
|
|
|
|
if res.Code != 0 {
|
|
|
|
|
c.JSON(200, res)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(200, ErrorResponse(err))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetShareDocPreview 创建分享Office文档预览地址
|
|
|
|
|
func GetShareDocPreview(c *gin.Context) {
|
|
|
|
|
var service share.SingleFileService
|
|
|
|
|
if err := c.ShouldBindQuery(&service); err == nil {
|
|
|
|
|
res := service.CreateDocPreviewSession(c)
|
|
|
|
|
c.JSON(200, res)
|
|
|
|
|
} else {
|
|
|
|
|
c.JSON(200, ErrorResponse(err))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|