summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorMicaël Bergeron <mbergeron@gitlab.com>2018-03-09 09:16:06 -0500
committerMicaël Bergeron <mbergeron@gitlab.com>2018-03-09 09:16:06 -0500
commitfc6587f1f21c97fa19e3ae7eaac4e9add7b107b8 (patch)
treed83947812fb500e5f437a0d672901861dae5a13e /lib/api/helpers.rb
parent6466739e2e61f790a9e1f09020dba710c4078a0f (diff)
downloadgitlab-ce-fc6587f1f21c97fa19e3ae7eaac4e9add7b107b8.tar.gz
Add proxy_download to perform proxied sending of all files
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb16
1 files changed, 8 insertions, 8 deletions
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