[#2918] Refactor FileStreamingUtil (#2921)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2026-02-13 17:11:43 +02:00
committed by GitHub
parent ef3900a31c
commit 520b887b70
6 changed files with 360 additions and 400 deletions

View File

@@ -69,6 +69,6 @@ public class MgmtDownloadArtifactResource implements MgmtDownloadArtifactRestApi
}
return FileStreamingUtil.writeFileResponse(file, artifact.getFilename(), artifact.getCreatedAt(),
RequestResponseContextHolder.getHttpServletResponse(), request, null);
request, RequestResponseContextHolder.getHttpServletResponse(), null);
}
}

View File

@@ -1537,16 +1537,13 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
.as("wrong metadata of the filename").isEqualTo("origFilename");
}
private void downloadAndVerify(final SoftwareModule sm, final byte[] random, final Artifact artifact)
throws Exception {
private void downloadAndVerify(final SoftwareModule sm, final byte[] random, final Artifact artifact) throws Exception {
final MvcResult result = mvc
.perform(
get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), artifact.getId()))
.perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), artifact.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM))
.andExpect(header().string("ETag", artifact.getSha1Hash()))
.andExpect(header().string("ETag", '"' + artifact.getSha1Hash() + '"'))
.andReturn();
assertArrayEquals(result.getResponse().getContentAsByteArray(), random, "Wrong response content");
}