Skip to content

Commit

Permalink
simplify streamin output creation
Browse files Browse the repository at this point in the history
  • Loading branch information
thoniTUB committed Aug 17, 2021
1 parent 077a4a9 commit cddbe19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,14 @@ public static <E extends ManagedExecution<?> & SingleTableResult> Response getAr
(EntityResult cer) -> ResultUtil.createId(namespace, cer, config.getIdMapping(), mappingState));


StreamingOutput out = new StreamingOutput() {

@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
renderToStream(writerProducer.apply(output),
settings,
config.getArrow().getBatchSize(),
idMappingConf.getPrintIdFields(),
exec.getResultInfo(),
exec.streamResults());

}
};

return makeResponseWithFileName(out, exec.getLabelWithoutAutoLabelSuffix(), fileExtension, mediaType, ResultUtil.ContentDispositionOption.attachment);
StreamingOutput out = output -> renderToStream(writerProducer.apply(output),
settings,
config.getArrow().getBatchSize(),
idMappingConf.getPrintIdFields(),
exec.getResultInfo(),
exec.streamResults());

return makeResponseWithFileName(out, exec.getLabelWithoutAutoLabelSuffix(), fileExtension, mediaType, ResultUtil.ContentDispositionOption.ATTACHMENT);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public <E extends ManagedExecution<?> & SingleTableResult> Response getResult(Us
throw new WebApplicationException("Failed to load result", e);
}
};
return makeResponseWithFileName(out, exec.getLabelWithoutAutoLabelSuffix(), "csv", new MediaType("text", "csv", charset.toString()), ResultUtil.ContentDispositionOption.attachment);
return makeResponseWithFileName(out, exec.getLabelWithoutAutoLabelSuffix(), "csv", new MediaType("text", "csv", charset.toString()), ResultUtil.ContentDispositionOption.ATTACHMENT);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public <E extends ManagedExecution<?> & SingleTableResult> Response getExcelResu
output
);

return makeResponseWithFileName(out, exec.getLabelWithoutAutoLabelSuffix(), "xlsx", MEDIA_TYPE, ResultUtil.ContentDispositionOption.attachment);
return makeResponseWithFileName(out, exec.getLabelWithoutAutoLabelSuffix(), "xlsx", MEDIA_TYPE, ResultUtil.ContentDispositionOption.ATTACHMENT);
}

}

0 comments on commit cddbe19

Please sign in to comment.