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
diff options
context:
space:
mode:
authorMicaël Bergeron <mbergeron@gitlab.com>2018-03-09 17:16:06 +0300
committerMicaël Bergeron <mbergeron@gitlab.com>2018-03-09 17:16:06 +0300
commitfc6587f1f21c97fa19e3ae7eaac4e9add7b107b8 (patch)
treed83947812fb500e5f437a0d672901861dae5a13e /app/controllers/concerns
parent6466739e2e61f790a9e1f09020dba710c4078a0f (diff)
Add proxy_download to perform proxied sending of all files
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r--app/controllers/concerns/send_file_upload.rb8
-rw-r--r--app/controllers/concerns/uploads_actions.rb12
2 files changed, 10 insertions, 10 deletions
diff --git a/app/controllers/concerns/send_file_upload.rb b/app/controllers/concerns/send_file_upload.rb
index d4de4cf1fda..e8636ab7901 100644
--- a/app/controllers/concerns/send_file_upload.rb
+++ b/app/controllers/concerns/send_file_upload.rb
@@ -1,12 +1,14 @@
module SendFileUpload
- def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil)
+ def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil, disposition: 'attachment')
if attachment
- redirect_params[:query] = { "response-content-disposition" => "attachment;filename=#{attachment.inspect}" }
- send_params.merge!(filename: attachment, disposition: 'attachment')
+ redirect_params[:query] = { "response-content-disposition" => "#{disposition};filename=#{attachment.inspect}" }
+ send_params.merge!(filename: attachment, disposition: disposition)
end
if file_upload.file_storage?
send_file file_upload.path, send_params
+ elsif file_upload.class.proxy_download_enabled?
+ Gitlab::Workhorse.send_url(file_upload.url(**redirect_params))
else
redirect_to file_upload.url(**redirect_params)
end
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb
index f4e19615760..b9b9b6e4e88 100644
--- a/app/controllers/concerns/uploads_actions.rb
+++ b/app/controllers/concerns/uploads_actions.rb
@@ -1,5 +1,6 @@
module UploadsActions
include Gitlab::Utils::StrongMemoize
+ include SendFileUpload
UPLOAD_MOUNTS = %w(avatar attachment file logo header_logo).freeze
@@ -26,14 +27,11 @@ module UploadsActions
def show
return render_404 unless uploader&.exists?
- if uploader.file_storage?
- disposition = uploader.image_or_video? ? 'inline' : 'attachment'
- expires_in 0.seconds, must_revalidate: true, private: true
+ expires_in 0.seconds, must_revalidate: true, private: true
- send_file uploader.file.path, disposition: disposition
- else
- redirect_to uploader.url
- end
+ disposition = uploader.image_or_video? ? 'inline' : 'attachment'
+
+ send_upload(uploader, attachment: uploader.filename, disposition: disposition)
end
private