mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Modify: parameters in headers should be URIEncoded
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/HFO4/cloudreve/pkg/serializer"
|
||||
"github.com/HFO4/cloudreve/pkg/util"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@@ -30,12 +31,20 @@ func FileUploadStream(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 解码文件名和路径
|
||||
fileName, err := url.QueryUnescape(c.Request.Header.Get("X-FileName"))
|
||||
filePath, err := url.QueryUnescape(c.Request.Header.Get("X-Path"))
|
||||
if err != nil {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
return
|
||||
}
|
||||
|
||||
fileData := local.FileStream{
|
||||
MIMEType: c.Request.Header.Get("Content-Type"),
|
||||
File: c.Request.Body,
|
||||
Size: fileSize,
|
||||
Name: c.Request.Header.Get("X-FileName"),
|
||||
VirtualPath: util.DotPathToStandardPath(c.Request.Header.Get("X-Path")),
|
||||
Name: fileName,
|
||||
VirtualPath: util.DotPathToStandardPath(filePath),
|
||||
}
|
||||
|
||||
// 创建文件系统
|
||||
|
||||
@@ -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{"X-PINGOTHER", "Content-Type"},
|
||||
AllowHeaders: []string{"Content-Length", "Content-Type", "X-Path", "X-FileName"},
|
||||
AllowCredentials: true,
|
||||
}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user