Hotfix: API Download is decompressed

This commit is contained in:
2025-01-26 00:22:50 +01:00
parent d5fb48ff3f
commit 71362bc079
2 changed files with 10 additions and 2 deletions
@@ -65,6 +65,10 @@ public class NodeData {
private SchematicFormat nodeFormat; private SchematicFormat nodeFormat;
public InputStream schemData() throws IOException { public InputStream schemData() throws IOException {
return schemData(true);
}
public InputStream schemData(boolean decompress) throws IOException {
try { try {
return selSchemData.select(rs -> { return selSchemData.select(rs -> {
rs.next(); rs.next();
@@ -73,7 +77,11 @@ public class NodeData {
if(rs.wasNull() || schemData.available() == 0) { if(rs.wasNull() || schemData.available() == 0) {
throw new SecurityException("SchemData is null"); throw new SecurityException("SchemData is null");
} }
return new GZIPInputStream(schemData); if (decompress) {
return new GZIPInputStream(schemData);
} else {
return schemData;
}
} catch (IOException e) { } catch (IOException e) {
throw new SecurityException("SchemData is wrong", e); throw new SecurityException("SchemData is wrong", e);
} }
@@ -95,7 +95,7 @@ fun Route.configureSchematic() {
} }
call.response.header("Content-Disposition", "attachment; filename=\"${node.name}${data.nodeFormat.fileEnding}\"") call.response.header("Content-Disposition", "attachment; filename=\"${node.name}${data.nodeFormat.fileEnding}\"")
call.respondBytes(data.schemData().readAllBytes(), contentType = ContentType.Application.OctetStream, status = HttpStatusCode.OK) call.respondBytes(data.schemData(false).readAllBytes(), contentType = ContentType.Application.OctetStream, status = HttpStatusCode.OK)
} }
get("/info") { get("/info") {
val node = call.receiveSchematic() ?: return@get val node = call.receiveSchematic() ?: return@get