add header: content disposition
This commit is contained in:
parent
a0e7425379
commit
a88d0e59f6
|
@ -37,17 +37,16 @@ public class PublicApiController {
|
||||||
res.sendError(HttpStatus.BAD_REQUEST.value(), "Invalid year");
|
res.sendError(HttpStatus.BAD_REQUEST.value(), "Invalid year");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String filename = String.format("%s_%s_%s.log", year, month, country);
|
||||||
|
|
||||||
res.setContentType(MediaType.TEXT_PLAIN.getType());
|
res.setContentType(MediaType.TEXT_PLAIN.getType());
|
||||||
final ServletOutputStream out = res.getOutputStream();
|
res.setHeader("Content-Disposition", "attachment; filename=" + filename);
|
||||||
|
|
||||||
dbUtils.obtainLogEntries(year, month, country).forEach(s -> {
|
try (final ServletOutputStream out = res.getOutputStream()) {
|
||||||
try {
|
for (final String s : dbUtils.obtainLogEntries(year, month, country)) {
|
||||||
IOUtils.write(s, out, StandardCharsets.UTF_8);
|
IOUtils.write(s, out, StandardCharsets.UTF_8);
|
||||||
} catch (final IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue