Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-12-21 16:38:04 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-12-21 17:18:32 +0300
commit0460c1bb4b0726be0d535a0a4043fbaaab154dc4 (patch)
treecae6a6228cef50edca5e7ac3714f597e6e71648e /lib
parentd4376e0c7fdcb0e8c8aa44ea2c6b425e46ac22f5 (diff)
Merge branch 'multipart-uploaded-file' into 'master'
Inject ::UploadedFile from Multipart middleware Closes #25888 See merge request !8215
Diffstat (limited to 'lib')
-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)