From 7e2b539de484ac4f2e97eafce6b8d63ffa2caf13 Mon Sep 17 00:00:00 2001 From: Thomas Balthazar Date: Tue, 24 May 2016 15:07:42 +0200 Subject: Max_File_Size setting in System Console > File Settings (#3070) --- api/admin.go | 4 ++-- api/file.go | 4 ++-- api/license.go | 9 +++++---- api/user.go | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) (limited to 'api') diff --git a/api/admin.go b/api/admin.go index 8f66f60c1..c2dfa37d0 100644 --- a/api/admin.go +++ b/api/admin.go @@ -437,13 +437,13 @@ func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) { return } - if r.ContentLength > model.MAX_FILE_SIZE { + if r.ContentLength > *utils.Cfg.FileSettings.MaxFileSize { c.Err = model.NewLocAppError("uploadBrandImage", "api.admin.upload_brand_image.too_large.app_error", nil, "") c.Err.StatusCode = http.StatusRequestEntityTooLarge return } - if err := r.ParseMultipartForm(model.MAX_FILE_SIZE); err != nil { + if err := r.ParseMultipartForm(*utils.Cfg.FileSettings.MaxFileSize); err != nil { c.Err = model.NewLocAppError("uploadBrandImage", "api.admin.upload_brand_image.parse.app_error", nil, "") return } diff --git a/api/file.go b/api/file.go index f4d1e0005..e29bb072a 100644 --- a/api/file.go +++ b/api/file.go @@ -77,13 +77,13 @@ func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) { return } - if r.ContentLength > model.MAX_FILE_SIZE { + if r.ContentLength > *utils.Cfg.FileSettings.MaxFileSize { c.Err = model.NewLocAppError("uploadFile", "api.file.upload_file.too_large.app_error", nil, "") c.Err.StatusCode = http.StatusRequestEntityTooLarge return } - err := r.ParseMultipartForm(model.MAX_FILE_SIZE) + err := r.ParseMultipartForm(*utils.Cfg.FileSettings.MaxFileSize) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/api/license.go b/api/license.go index 1dbb2b281..f9ecce486 100644 --- a/api/license.go +++ b/api/license.go @@ -5,12 +5,13 @@ package api import ( "bytes" - l4g "github.com/alecthomas/log4go" - "github.com/mattermost/platform/model" - "github.com/mattermost/platform/utils" "io" "net/http" "strings" + + l4g "github.com/alecthomas/log4go" + "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" ) const ( @@ -48,7 +49,7 @@ func LoadLicense() { func addLicense(c *Context, w http.ResponseWriter, r *http.Request) { c.LogAudit("attempt") - err := r.ParseMultipartForm(model.MAX_FILE_SIZE) + err := r.ParseMultipartForm(*utils.Cfg.FileSettings.MaxFileSize) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/api/user.go b/api/user.go index ac99bd21b..628e978e9 100644 --- a/api/user.go +++ b/api/user.go @@ -1178,13 +1178,13 @@ func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) { return } - if r.ContentLength > model.MAX_FILE_SIZE { + if r.ContentLength > *utils.Cfg.FileSettings.MaxFileSize { c.Err = model.NewLocAppError("uploadProfileImage", "api.user.upload_profile_user.too_large.app_error", nil, "") c.Err.StatusCode = http.StatusRequestEntityTooLarge return } - if err := r.ParseMultipartForm(model.MAX_FILE_SIZE); err != nil { + if err := r.ParseMultipartForm(*utils.Cfg.FileSettings.MaxFileSize); err != nil { c.Err = model.NewLocAppError("uploadProfileImage", "api.user.upload_profile_user.parse.app_error", nil, "") return } -- cgit v1.2.3-1-g7c22