Skip to content

Commit

Permalink
zipping when its dir
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 committed Oct 25, 2024
1 parent e8b79a4 commit ab0a86b
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,20 @@ private ResponseEntity<StreamingResponseBody> handleInternalLobDownload(String d

if (version.equals(ViewerConstants.SIARD_DK_1007) || version.equals(ViewerConstants.SIARD_DK_128)) {
String filePath = row.getCells().get(row.getCells().keySet().toArray()[row.getCells().size() - 1]).getValue();
return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
DownloadUtils.stream(new BufferedInputStream(new FileInputStream(filePath)))));
if (Paths.get(filePath).toFile().isDirectory()) {
// handle lob as internal on separated folder
ZipFile zipFile = new ZipFile(filePath);
final ZipEntry entry = zipFile.getEntry(filePath);
if (entry == null) {
throw new GenericException("Zip archive entry is missing");
}

return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
DownloadUtils.stream(new BufferedInputStream(zipFile.getInputStream(entry)))));
} else {
return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType,
DownloadUtils.stream(new BufferedInputStream(new FileInputStream(filePath)))));
}
} else {
if (LobManagerUtils.isLobEmbedded(tableConfiguration, row, columnIndex)) {
// handle lob as embedded
Expand Down

0 comments on commit ab0a86b

Please sign in to comment.