diff options
Diffstat (limited to 'lib/api')
| -rw-r--r-- | lib/api/helpers.rb | 8 | ||||
| -rw-r--r-- | lib/api/runner.rb | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index cc81e4d3595..d4ca945873c 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -418,13 +418,17 @@ module API end end - def present_artifacts!(artifacts_file) + def present_artifacts!(artifacts_file, direct_download: true) return not_found! unless artifacts_file.exists? if artifacts_file.file_storage? present_file!(artifacts_file.path, artifacts_file.filename) - else + elsif direct_download redirect(artifacts_file.url) + else + header(*Gitlab::Workhorse.send_url(artifacts_file.url)) + status :ok + body end end diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 1f80646a2ea..e6e85d41806 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -244,11 +244,12 @@ module API params do requires :id, type: Integer, desc: %q(Job's ID) optional :token, type: String, desc: %q(Job's authentication token) + optional :direct_download, default: false, type: Boolean, desc: %q(Perform direct download from remote storage instead of proxying artifacts) end get '/:id/artifacts' do job = authenticate_job! - present_artifacts!(job.artifacts_file) + present_artifacts!(job.artifacts_file, direct_download: params[:direct_download]) end end end |
