Basically I need to provide REST service that would receive a String param, use that param to fetch a file from another system and then return the fetched file back as the response.
The effect should be the same as when a user clicks on a pdf or any other binary file link and the browser prompts him to save/download that file.
A couple of points:
return response.build()
?How do I go around doing this using Apache Wink?
PS Sorry, this may be trivial for Wink gurus, but I'm just starting to wrap my head around developer guide.
You can just return the java.io.File
from your method. You can wrap it with Response
if you like. Wink will handle the streaming. The streaming doesn't start when you call to response.build()
, but rather when your method finishes.
If you want a correct download dialog, you should return the proper Content-Disposition
header. See How to set response header in JAX-RS so that user sees download popup for Excel?