I find there is a feature in “sonar-cfamily-plugin”: user can download bundle file from server. “http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip”
I want to develop similar feature, the below is my code.
It works but I wish to know whether it is right or not?
@ServerSide
@ExtensionPoint
public class DownloadService implements WebService {
@Override
public void define(Context context) {
NewController controller = context.createController("static/bundle");
controller.setDescription("Download demo");
controller.createAction("download").setHandler(new RequestHandler() {
@Override
public void handle(Request request, Response response) throws Exception {
Response.Stream stream = response.stream();
stream.setMediaType("application/zip");
OutputStream out = stream.output();
out.write(.......); // copy stream in jar resources to out
out.flush();
out.close();
}
});
controller.done();
}
}
Thanks