Add streaming support for files in RESTEasy Reactive
See original GitHub issueDescription
It would be nice to have a simple way to return file content as a stream in a reactive way in a REST resource method.
The original discussion is here.
Implementation ideas
This discussion took place on Zulip so I’m only conveying the ideas discussed there (by other people).
@geoand suggested to Stephane Epardaud making AsyncFile
a known return type and properly handling it under the covers.
@Ladicek chimed in with:
Ladislav Thon: don’t we have a way to do an equivalent of Vert.x’s ReadStream.pipeTo(WriteStream)? Ladislav Thon: I know we don’t support StreamOutput in RESTEasy Reactive, but having a non-blocking variant of that would be really nice IMHO
Also, something to keep in mind is that it would be nice if a solution to this supported both whole files as well as some range from a file. I don’t know enough about the Vert.X FS API to know if this would be handled transparently by calling AsyncFile.setReadPos(long)
and AsyncFile.setReadLength(long)
before returning it or whether some special handling would be required for this.
Issue Analytics
- State:
- Created 3 years ago
- Comments:43 (30 by maintainers)
The problem you mentione above has nothing to do with Quarkus, it’s a limitation of the
var
usage. If you usefinal StreamingOutput streamingOutput
then everything works as expectedI’m using RestAssured to test my resources. Is it expected behaviour when returning a StreamingOutput, that the body is initially empty? How would you test this with RestAssured?
Real code:
The test: