summaryrefslogtreecommitdiff
path: root/lib/gitlab/middleware
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2016-12-21 11:44:47 +0100
committerJacob Vosmaer <jacob@gitlab.com>2016-12-21 13:07:53 +0100
commit4ec259fd36fe57aa95446c10a47d784dae2c8f00 (patch)
treec5ee8fb121be2decb38b9f6ba1a105c69f641db5 /lib/gitlab/middleware
parent46920f7e371debe6af526ab9476aef6ca452185b (diff)
downloadgitlab-ce-4ec259fd36fe57aa95446c10a47d784dae2c8f00.tar.gz
Inject ::UploadedFile from Multipart middleware
I mistakenly concluded Rack::Multipart injects File instances into the params. These should be UploadedFile instances. This reuses a mock UploadedFile class we already had in GitLab.
Diffstat (limited to 'lib/gitlab/middleware')
-rw-r--r--lib/gitlab/middleware/multipart.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/middleware/multipart.rb b/lib/gitlab/middleware/multipart.rb
index 65713e73a59..dd99f9bb7d7 100644
--- a/lib/gitlab/middleware/multipart.rb
+++ b/lib/gitlab/middleware/multipart.rb
@@ -42,7 +42,7 @@ module Gitlab
key, value = parsed_field.first
if value.nil?
- value = File.open(tmp_path)
+ value = open_file(tmp_path)
@open_files << value
else
value = decorate_params_value(value, @request.params[key], tmp_path)
@@ -68,7 +68,7 @@ module Gitlab
case path_value
when nil
- value_hash[path_key] = File.open(tmp_path)
+ value_hash[path_key] = open_file(tmp_path)
@open_files << value_hash[path_key]
value_hash
when Hash
@@ -78,6 +78,10 @@ module Gitlab
raise "unexpected path value: #{path_value.inspect}"
end
end
+
+ def open_file(path)
+ ::UploadedFile.new(path, File.basename(path), 'application/octet-stream')
+ end
end
def initialize(app)