diff options
Diffstat (limited to 'api4')
-rw-r--r-- | api4/file.go | 8 | ||||
-rw-r--r-- | api4/file_test.go | 9 |
2 files changed, 15 insertions, 2 deletions
diff --git a/api4/file.go b/api4/file.go index 6bd751a67..09132b9a1 100644 --- a/api4/file.go +++ b/api4/file.go @@ -33,9 +33,13 @@ func InitFile() { } func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) { + if !*utils.Cfg.FileSettings.EnableFileAttachments { + c.Err = model.NewAppError("uploadFile", "api.file.attachments.disabled.app_error", nil, "", http.StatusNotImplemented) + return + } + 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 + c.Err = model.NewAppError("uploadFile", "api.file.upload_file.too_large.app_error", nil, "", http.StatusRequestEntityTooLarge) return } diff --git a/api4/file_test.go b/api4/file_test.go index 9124e893b..e48aabffc 100644 --- a/api4/file_test.go +++ b/api4/file_test.go @@ -102,6 +102,15 @@ func TestUploadFile(t *testing.T) { _, resp = th.SystemAdminClient.UploadFile(data, channel.Id, "test.png") CheckNoError(t, resp) + + enableFileAttachments := *utils.Cfg.FileSettings.EnableFileAttachments + defer func() { + *utils.Cfg.FileSettings.EnableFileAttachments = enableFileAttachments + }() + *utils.Cfg.FileSettings.EnableFileAttachments = false + + _, resp = th.SystemAdminClient.UploadFile(data, channel.Id, "test.png") + CheckNotImplementedStatus(t, resp) } func TestGetFile(t *testing.T) { |