diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-03 08:47:55 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-03 08:47:55 +0000 |
commit | 317206300d56eb2fc4f7c3701151f47f8f1e6eef (patch) | |
tree | ce000f92bbeae56cd7468053594eb4a9393444c1 /app/services | |
parent | 0d0042d27481d31027a10edb2ba3a184bff5075a (diff) | |
parent | dfd256f29ee817b5ffc563bb554a02d26ae44502 (diff) | |
download | gitlab-ce-317206300d56eb2fc4f7c3701151f47f8f1e6eef.tar.gz |
Merge branch 'configurable-attachment-size' into 'master'
Support configurable attachment size in Application Settings page
### What does this MR do?
This MR provides the ability to configure the maximum size of an attachment inside a note. A parameter has been added to the Application Settings page.
### Are there points in the code the reviewer needs to double check?
What should be done with the legacy note attachment validation? I added code to make the validation work with the configurable setting. I could see an issue where an admin lowers the limit from 10 megabytes to 5 megabytes, which could cause an existing model to be invalid.
### Why was this MR needed?
We often have attachments that exceed 10 MB, and it would be nice to be able to override the defaults.
### What are the relevant issue numbers / [Feature requests](http://feedback.gitlab.com/)?
See Issue #1258
### Screenshots
Before:

After:

See merge request !407
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/upload_service.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/projects/upload_service.rb b/app/services/projects/upload_service.rb index a186c97628f..992a7a7a1dc 100644 --- a/app/services/projects/upload_service.rb +++ b/app/services/projects/upload_service.rb @@ -5,7 +5,7 @@ module Projects end def execute - return nil unless @file + return nil unless @file and @file.size <= max_attachment_size uploader = FileUploader.new(@project) uploader.store!(@file) @@ -18,5 +18,11 @@ module Projects 'is_image' => uploader.image? } end + + private + + def max_attachment_size + current_application_settings.max_attachment_size.megabytes.to_i + end end end |