Skip to content

Commit

Permalink
feat(emm): hint download type in parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
olovy committed Nov 27, 2024
1 parent ffe7048 commit 6fe3820
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions emm/src/main/java/whelk/Dump.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class Dump {
private static final String DUMP_END_MARKER = DUMP_END_MARKER_NO_NEWLINE + "\n"; // Must be 17 bytes
private static final String JSON_CONTENT_TYPE = "application/json";
private static final int GZIP_BUF_SIZE = 64 * 1024;
private static final String ND_JSON_LD_GZ_EXT = ".jsonld.gz";

public static void sendDumpResponse(Whelk whelk, String apiBaseUrl, HttpServletRequest req, HttpServletResponse res) throws IOException, SQLException {
String selection = req.getParameter("selection");
Expand Down Expand Up @@ -110,7 +111,7 @@ private static void sendDumpEntryPoint(String apiBaseUrl, String selection, Http
responseObject.put("@context", contexts);
responseObject.put("type", "Collection");
responseObject.put("id", apiBaseUrl + "?selection=" + selection);
responseObject.put("url", apiBaseUrl + "?selection=" + selection + "&download");
responseObject.put("url", apiBaseUrl + "?selection=" + selection + "&download=" + ND_JSON_LD_GZ_EXT);
var first = new LinkedHashMap<>();
first.put("type", "CollectionPage");
first.put("id", apiBaseUrl + "?selection=" + selection + "&offset=0");
Expand Down Expand Up @@ -284,7 +285,7 @@ private static void sendFormattedResponse(Whelk whelk, String apiBaseUrl, String
}

private static void sendDumpDownloadResponse(Whelk whelk, String apiBaseUrl, String dump, Path dumpFilePath, HttpServletResponse res) {
String filename = Unicode.stripSuffix(dumpFilePath.getFileName().toString(), ".dump") + ".ndjsonld.gz";
String filename = Unicode.stripSuffix(dumpFilePath.getFileName().toString(), ".dump") + ND_JSON_LD_GZ_EXT;
res.setHeader("Content-Disposition", "attachment; filename=" + filename);
res.setHeader("Content-Type", "application/octet-stream");

Expand Down

0 comments on commit 6fe3820

Please sign in to comment.