How do send a file for download using jax-rs?
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
public Response getFile(String contentType) {
File f = new File("/tmp/file.doc");
ResponseBuilder response = Response.ok(f);
response.type(contentType);
response.header("Content-Disposition", "attachment; filename=\"file.doc\"");
return response.build();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With