Skip to content

Commit

Permalink
feat(download): implement download piping as default rather than pres…
Browse files Browse the repository at this point in the history
…igned URLs
  • Loading branch information
andrewazores committed Feb 13, 2024
1 parent d42a2c2 commit bef73de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/io/cryostat/ConfigProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ public class ConfigProperties {
public static final String GRAFANA_DATASOURCE_URL = "grafana-datasource.url";

public static final String STORAGE_EXT_URL = "storage-ext.url";
public static final String STORAGE_PRESIGNED_DOWNLOADS_ENABLED =
"storage.presigned-downloads.enabled";
}
13 changes: 11 additions & 2 deletions src/main/java/io/cryostat/recordings/Recordings.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public class Recordings {
@ConfigProperty(name = ConfigProperties.GRAFANA_DATASOURCE_URL)
Optional<String> grafanaDatasourceURL;

@ConfigProperty(name = ConfigProperties.STORAGE_PRESIGNED_DOWNLOADS_ENABLED)
boolean presignedDownloadsEnabled;

@ConfigProperty(name = ConfigProperties.STORAGE_EXT_URL)
Optional<String> externalStorageUrl;

Expand Down Expand Up @@ -959,7 +962,7 @@ public Map<String, Object> patchRecordingOptions(
@Blocking
@Path("/api/v3/activedownload/{id}")
@RolesAllowed("read")
public Response createAndRedirectPresignedDownload(@RestPath long id) throws Exception {
public Response createAndRedirectDownload(@RestPath long id) throws Exception {
ActiveRecording recording = ActiveRecording.findById(id);
if (recording == null) {
throw new NotFoundException();
Expand Down Expand Up @@ -992,8 +995,14 @@ public Response createAndRedirectPresignedDownload(@RestPath long id) throws Exc
@Blocking
@Path("/api/v3/download/{encodedKey}")
@RolesAllowed("read")
public Response redirectPresignedDownload(@RestPath String encodedKey, @RestQuery String f)
public Response handleStorageDownload(@RestPath String encodedKey, @RestQuery String f)
throws URISyntaxException {
if (!presignedDownloadsEnabled) {
return Response.status(RestResponse.Status.OK)
.entity(recordingHelper.getArchivedRecordingStream(encodedKey))
.build();
}

Pair<String, String> pair = recordingHelper.decodedKey(encodedKey);
logger.infov("Handling presigned download request for {0}", pair);
GetObjectRequest getRequest =
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ quarkus.http.filter.static.methods=GET
quarkus.http.filter.static.order=1

storage-ext.url=
storage.presigned-downloads.enabled=false
storage.buckets.archives.name=archivedrecordings
storage.buckets.archives.expiration-label=expiration

Expand Down

0 comments on commit bef73de

Please sign in to comment.