Skip to content

Commit

Permalink
Fixed artifact endpoint by defining the endpoint will produce a file …
Browse files Browse the repository at this point in the history
…response rather than json.
  • Loading branch information
BeatBaechi committed Jan 23, 2024
1 parent 505bfb0 commit 87d976c
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions source/Jobbr.Server.WebAPI/Controller/JobRunController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using Jobbr.ComponentModel.Management;
using Jobbr.ComponentModel.Management.Model;
using Jobbr.Server.WebAPI.Controller.Mapping;
Expand Down Expand Up @@ -152,6 +149,7 @@ public IActionResult GetJobRunsByTrigger(long jobId, long triggerId, int page =
/// <param name="filename">Filename.</param>
/// <returns>The artifact.</returns>
[HttpGet("jobruns/{jobRunId}/artefacts/{filename}")]
[Produces("application/octet-stream")]
public IActionResult GetArtefact(long jobRunId, string filename)
{
var jobRun = _queryService.GetJobRunById(jobRunId);
Expand All @@ -163,14 +161,7 @@ public IActionResult GetArtefact(long jobRunId, string filename)

var fileStream = _jobManagementService.GetArtefactAsStream(jobRun.Id, filename);

var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StreamContent(fileStream)
};

result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

return Ok(result);
return new FileStreamResult(fileStream, "application/octet-stream");
}

/// <summary>
Expand Down

0 comments on commit 87d976c

Please sign in to comment.