diff options
author | Nick Thomas <nick@gitlab.com> | 2018-02-12 22:24:34 +0300 |
---|---|---|
committer | Mark Fletcher <mark@gitlab.com> | 2018-02-14 14:50:13 +0300 |
commit | be0785ed81fdde5d88db07f992adaa9326e2dd9c (patch) | |
tree | 3e6f207779681c9d7f700c7b55ece76027c91add /lib | |
parent | ed9f6c845911eacba1b74f61df319eef76e3b701 (diff) |
Merge branch 'ac/4878-fix-attachments-ext' into 'master'
Honour workhorse provided file name
See merge request gitlab-org/gitlab-ce!17059
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/middleware/multipart.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/gitlab/middleware/multipart.rb b/lib/gitlab/middleware/multipart.rb index cc1e92480be..d4c54049b74 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 = open_file(tmp_path) + value = open_file(tmp_path, @request.params["#{key}.name"]) @open_files << value else value = decorate_params_value(value, @request.params[key], tmp_path) @@ -70,7 +70,7 @@ module Gitlab case path_value when nil - value_hash[path_key] = open_file(tmp_path) + value_hash[path_key] = open_file(tmp_path, value_hash.dig(path_key, '.name')) @open_files << value_hash[path_key] value_hash when Hash @@ -81,8 +81,8 @@ module Gitlab end end - def open_file(path) - ::UploadedFile.new(path, File.basename(path), 'application/octet-stream') + def open_file(path, name) + ::UploadedFile.new(path, name || File.basename(path), 'application/octet-stream') end end |