From 0d239a08917d8762a5d7d6993769f5bdc91872fd Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 8 Dec 2017 08:03:33 +0400 Subject: [PATCH 1/2] Moved file size limit to config file --- app_config.defaults.rb | 1 + helpers/appinit.rb | 1 + routes/tickets.rb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app_config.defaults.rb b/app_config.defaults.rb index 450a052..7117f87 100644 --- a/app_config.defaults.rb +++ b/app_config.defaults.rb @@ -108,4 +108,5 @@ class AppConfig UPLOAD_DIR = 'public/uploads' UPLOAD_FILE_EXTS = ['.doc', '.docx', '.xls', '.xlsx', '.pdf', '.eml', '.jpg', '.png', '.jpeg', '.tif'] + UPLOAD_MAX_SIZE = 2000000 #In bytes end diff --git a/helpers/appinit.rb b/helpers/appinit.rb index bdd6261..bc7900d 100644 --- a/helpers/appinit.rb +++ b/helpers/appinit.rb @@ -32,5 +32,6 @@ def initialize() @uploaddir = (defined? AppConfig::UPLOAD_DIR != nil) ? AppConfig::UPLOAD_DIR : 'public/uploads' @uploadfilter = ((defined? AppConfig::UPLOAD_FILE_EXTS != nil) && AppConfig::UPLOAD_FILE_EXTS != []) ? (AppConfig::UPLOAD_FILE_EXTS.map { |x| x.downcase }) : [] + @uploadmaxsize = (defined? AppConfig::UPLOAD_MAX_SIZE != nil) && AppConfig::UPLOAD_MAX_SIZE > 0 ? AppConfig::UPLOAD_MAX_SIZE : -1 end end \ No newline at end of file diff --git a/routes/tickets.rb b/routes/tickets.rb index ef55f2a..652fe3e 100644 --- a/routes/tickets.rb +++ b/routes/tickets.rb @@ -370,7 +370,7 @@ class Helpdesk < Sinatra::Base end #File size limit check - if @params[:file][:tempfile].size > 2000000 + if @uploadmaxsize != -1 && @params[:file][:tempfile].size > @uploadmaxsize redirect '/ticket-detail/'+@params[:ticket]+'?msg=File: '+@params[:file][:filename]+' has exceeded the 2 MB file size limit.' return end From f065cef7210d879b1a5d80761485abd10e94d978 Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 8 Dec 2017 09:03:15 +0400 Subject: [PATCH 2/2] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8897fcf..cdb57e0 100644 --- a/README.md +++ b/README.md @@ -126,8 +126,9 @@ We use [SemVer](http://semver.org/) for versioning. For the versions available, The following individuals contributed code to this project: +* [Ilin Dmitry](https://github.com/IlinDmitry) * [Kevin Smith](https://github.com/kvsm) -* Nitin Reddy +* [Nitin Reddy](https://github.com/redknitin) * _When we accept your pull request or patch, your name will appear here_ ## License