package PreviewController import ( "dsSupport/Utils/CommonUtil" "dsSupport/Utils/ObsUtil" "github.com/gin-gonic/gin" "net/http" ) //模块的路由配置 func Routers(r *gin.RouterGroup) { rr := r.Group("/preview") //配置接口 rr.GET("/preview", preview) return } // http://127.0.0.1:9000/support/preview/preview func preview(c *gin.Context) { //本地物理路径 p :=c.Query("p") fullPath:="C:\\Users\\Administrator\\Desktop\\技术讨论会\\"+p //判断是不是本地存在 isExist, err := CommonUtil.PathExists(fullPath) if err != nil { c.String(http.StatusOK, "发生严重错误:"+err.Error()) return } if !isExist { c.String(http.StatusOK, "输入的文件无法找到!") return } //将文件上传到华为云 key := "dsMinPreview/" + p ObsUtil.UploadFileMultiPart(key, fullPath) //返回地址 url := "http://ow365.cn/?i=14531&fname=" + p + "&furl=http%3A%2F%2Fvideo.edusoa.com%2F" + key //输出预览地址 c.String(http.StatusOK, url) }