I am using Akka HTTP 10.1.11
HttpEntities.create supports creating from File or ByteString but not from OutputStream. How to create akka.http.javadsl.model.ResponseEntity from OutputStream?
Currently I am creating as below
Source<ByteString, OutputStream> source = StreamConverters.asOutputStream().mapMaterializedValue(os -> {
client.download(os);// This will connect to 3rd party service, and receives file content in outputstream
return os;
});
ResponseEntity resposeEntity = HttpEntities.create(ContentTypes.APPLICATION_OCTET_STREAM, preAuthData.getFileSize(), source);
(ContentTypes.APPLICATION_OCTET_STREAM, fileSize, source);
However, the above is throwing exception
filestore-cluster-akka.actor.default-dispatcher-9 akka.actor.ActorSystemImpl Rendering of response failed because response entity stream materialization failed with ‘java.io.IOException: java.util.concurrent.TimeoutException: Futures timed out after [5 seconds]’. Sending out 500 response instead.
java.io.UncheckedIOException: java.io.IOException: java.util.concurrent.TimeoutException: Futures timed out after [5 seconds]