From fc6587f1f21c97fa19e3ae7eaac4e9add7b107b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mica=C3=ABl=20Bergeron?= Date: Fri, 9 Mar 2018 09:16:06 -0500 Subject: Add proxy_download to perform proxied sending of all files --- lib/api/helpers.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/api/helpers.rb') diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index de9058ce71f..e59e8a45908 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -410,7 +410,7 @@ module API ) end - def present_file!(path, filename, content_type = 'application/octet-stream') + def present_disk_file!(path, filename, content_type = 'application/octet-stream') filename ||= File.basename(path) header['Content-Disposition'] = "attachment; filename=#{filename}" header['Content-Transfer-Encoding'] = 'binary' @@ -426,15 +426,15 @@ module API end end - def present_artifacts!(artifacts_file, direct_download: true) - return not_found! unless artifacts_file.exists? + def present_carrierwave_file!(file, supports_direct_download: true) + return not_found! unless file.exists? - if artifacts_file.file_storage? - present_file!(artifacts_file.path, artifacts_file.filename) - elsif direct_download - redirect(artifacts_file.url) + if file.file_storage? + present_disk_file!(file.path, file.filename) + elsif supports_direct_download && file.class.direct_download_enabled? + redirect(file.url) else - header(*Gitlab::Workhorse.send_url(artifacts_file.url)) + header(*Gitlab::Workhorse.send_url(file.url)) status :ok body end -- cgit v1.2.1