final String filename = "upload/file-" + UUID.randomUUID().toString() + ".upload";
vertx.fileSystem().open(filename, new AsyncResultHandler<AsyncFile>() {
public void handle(AsyncResult<AsyncFile> ar) {
final AsyncFile file = ar.result;
final Pump pump = Pump.createPump(req, file.getWriteStream());
final long start = System.currentTimeMillis();
req.endHandler(new SimpleHandler() {
public void handle() {
file.close(new AsyncResultHandler<Void>() {
public void handle(AsyncResult<Void> ar) {
if (ar.exception == null) {
req.response.end();
long end = System.currentTimeMillis();
System.out.println("Uploaded " + pump.getBytesPumped() + " bytes to " + filename + " in " + (end - start) + " ms");