修复文件上传超过1GB报错的bug

This commit is contained in:
gsw945
2023-03-20 14:30:27 +08:00
parent 5f3b2fa1ef
commit 4cdafc80b4
4 changed files with 45 additions and 34 deletions

View File

@@ -111,8 +111,8 @@ func RegisterModel() {
new(models.TeamMember),
new(models.TeamRelationship),
new(models.Itemsets),
new(models.Comment),
new(models.WorkWeixinAccount),
new(models.Comment),
new(models.WorkWeixinAccount),
)
gob.Register(models.Blog{})
gob.Register(models.Document{})
@@ -207,7 +207,7 @@ func RegisterCommand() {
}
//注册模板函数
// 注册模板函数
func RegisterFunction() {
err := web.AddFuncMap("config", models.GetOptionValue)
@@ -294,7 +294,7 @@ func RegisterFunction() {
}
}
//解析命令
// 解析命令
func ResolveCommand(args []string) {
flagSet := flag.NewFlagSet("MinDoc command: ", flag.ExitOnError)
flagSet.StringVar(&conf.ConfigurationFile, "config", "", "MinDoc configuration file.")
@@ -343,6 +343,10 @@ func ResolveCommand(args []string) {
web.BConfig.WebConfig.StaticDir["/uploads"] = uploads
web.BConfig.WebConfig.ViewsPath = conf.WorkingDir("views")
web.BConfig.WebConfig.Session.SessionCookieSameSite = http.SameSiteDefaultMode
var upload_file_size = conf.GetUploadFileSize()
if upload_file_size > web.BConfig.MaxUploadSize {
web.BConfig.MaxUploadSize = upload_file_size
}
fonts := conf.WorkingDir("static", "fonts")
@@ -362,7 +366,7 @@ func ResolveCommand(args []string) {
}
//注册缓存管道
// 注册缓存管道
func RegisterCache() {
isOpenCache := web.AppConfig.DefaultBool("cache", false)
if !isOpenCache {
@@ -461,7 +465,7 @@ func RegisterCache() {
logs.Info("缓存初始化完成.")
}
//自动加载配置文件.修改了监听端口号和数据库配置无法自动生效.
// 自动加载配置文件.修改了监听端口号和数据库配置无法自动生效.
func RegisterAutoLoadConfig() {
if conf.AutoLoadDelay > 0 {
@@ -502,7 +506,7 @@ func RegisterAutoLoadConfig() {
}
}
//注册错误处理方法.
// 注册错误处理方法.
func RegisterError() {
web.ErrorHandler("404", func(writer http.ResponseWriter, request *http.Request) {
var buf bytes.Buffer