diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-06-27 12:54:46 +0200 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-06-27 12:54:46 +0200 |
commit | 249c24891a3a54d2fd6b9355244cad4e35d722f7 (patch) | |
tree | 780a3835a59c22a7a4c4380981ce69d787ff2046 /lib | |
parent | ad086fa8d8278f9e2d88b8c8357b7ab5e7a5879b (diff) | |
download | gitlab-ce-249c24891a3a54d2fd6b9355244cad4e35d722f7.tar.gz |
Updated multipart to support workhorse direct uploads
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/middleware/multipart.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/gitlab/middleware/multipart.rb b/lib/gitlab/middleware/multipart.rb index a5f5d719cc1..9753be6d5c3 100644 --- a/lib/gitlab/middleware/multipart.rb +++ b/lib/gitlab/middleware/multipart.rb @@ -42,10 +42,10 @@ module Gitlab key, value = parsed_field.first if value.nil? - value = open_file(tmp_path, @request.params["#{key}.name"]) + value = open_file(@request.params, key) @open_files << value else - value = decorate_params_value(value, @request.params[key], tmp_path) + value = decorate_params_value(value, @request.params[key]) end @request.update_param(key, value) @@ -57,7 +57,7 @@ module Gitlab end # This function calls itself recursively - def decorate_params_value(path_hash, value_hash, tmp_path) + def decorate_params_value(path_hash, value_hash) unless path_hash.is_a?(Hash) && path_hash.count == 1 raise "invalid path: #{path_hash.inspect}" end @@ -70,19 +70,21 @@ module Gitlab case path_value when nil - value_hash[path_key] = open_file(tmp_path, value_hash.dig(path_key, '.name')) + value_hash[path_key] = open_file(value_hash.dig(path_key), '') @open_files << value_hash[path_key] value_hash when Hash - decorate_params_value(path_value, value_hash[path_key], tmp_path) + decorate_params_value(path_value, value_hash[path_key]) value_hash else raise "unexpected path value: #{path_value.inspect}" end end - def open_file(path, name) - ::UploadedFile.new(path, filename: name || File.basename(path), content_type: 'application/octet-stream') + def open_file(params, key) + ::UploadedFile.from_params( + params, key, + Gitlab.config.uploads.storage_path) end end |