summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorThomas Balthazar <tbalthazar@users.noreply.github.com>2016-05-24 15:07:42 +0200
committerHarrison Healey <harrisonmhealey@gmail.com>2016-05-24 09:07:42 -0400
commit7e2b539de484ac4f2e97eafce6b8d63ffa2caf13 (patch)
treee85b742e695c611958f249a4e39d0e6370c1f9b0 /model
parent8e5c31859012516afcfc28eddbb644a4c96fe9d3 (diff)
downloadchat-7e2b539de484ac4f2e97eafce6b8d63ffa2caf13.tar.gz
chat-7e2b539de484ac4f2e97eafce6b8d63ffa2caf13.tar.bz2
chat-7e2b539de484ac4f2e97eafce6b8d63ffa2caf13.zip
Max_File_Size setting in System Console > File Settings (#3070)
Diffstat (limited to 'model')
-rw-r--r--model/config.go10
-rw-r--r--model/file.go4
2 files changed, 10 insertions, 4 deletions
diff --git a/model/config.go b/model/config.go
index ecfd18710..08b00b90f 100644
--- a/model/config.go
+++ b/model/config.go
@@ -92,6 +92,7 @@ type LogSettings struct {
}
type FileSettings struct {
+ MaxFileSize *int64
DriverName string
Directory string
EnablePublicLink bool
@@ -263,6 +264,11 @@ func (o *Config) SetDefaults() {
o.SqlSettings.AtRestEncryptKey = NewRandomString(32)
}
+ if o.FileSettings.MaxFileSize == nil {
+ o.FileSettings.MaxFileSize = new(int64)
+ *o.FileSettings.MaxFileSize = 52428800 // 50 MB
+ }
+
if len(o.FileSettings.PublicLinkSalt) == 0 {
o.FileSettings.PublicLinkSalt = NewRandomString(32)
}
@@ -569,6 +575,10 @@ func (o *Config) IsValid() *AppError {
return NewLocAppError("Config.IsValid", "model.config.is_valid.sql_max_conn.app_error", nil, "")
}
+ if *o.FileSettings.MaxFileSize <= 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.max_file_size.app_error", nil, "")
+ }
+
if !(o.FileSettings.DriverName == IMAGE_DRIVER_LOCAL || o.FileSettings.DriverName == IMAGE_DRIVER_S3) {
return NewLocAppError("Config.IsValid", "model.config.is_valid.file_driver.app_error", nil, "")
}
diff --git a/model/file.go b/model/file.go
index b7806b3b4..fa98a3b3a 100644
--- a/model/file.go
+++ b/model/file.go
@@ -8,10 +8,6 @@ import (
"io"
)
-const (
- MAX_FILE_SIZE = 50000000 // 50 MB
-)
-
var (
IMAGE_EXTENSIONS = [5]string{".jpg", ".jpeg", ".gif", ".bmp", ".png"}
IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff"}