Modify: use uri parameter in Get File

This commit is contained in:
HFO4
2019-11-29 15:24:23 +08:00
parent 2c2ee5b1c1
commit 0cbbe5bb79
5 changed files with 15 additions and 8 deletions

View File

@@ -20,7 +20,7 @@ func Download(c *gin.Context) {
defer cancel()
var service explorer.FileDownloadService
if err := c.ShouldBindQuery(&service); err == nil {
if err := c.ShouldBindUri(&service); err == nil {
res := service.Download(ctx, c)
if res.Code != 0 {
c.JSON(200, res)

View File

@@ -21,7 +21,7 @@ func InitRouter() *gin.Engine {
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"http://localhost:3000"},
AllowMethods: []string{"PUT", "POST", "GET", "OPTIONS"},
AllowHeaders: []string{"Content-Length", "Content-Type", "X-Path", "X-FileName"},
AllowHeaders: []string{"Cookie", "Content-Length", "Content-Type", "X-Path", "X-FileName"},
AllowCredentials: true,
}))
@@ -63,7 +63,7 @@ func InitRouter() *gin.Engine {
// 文件上传
file.POST("upload", controllers.FileUploadStream)
// 下载文件
file.GET("", controllers.Download)
file.GET("*path", controllers.Download)
}
// 目录