Package org.vertx.java.core.streams

Examples of org.vertx.java.core.streams.Pump


            if (ar.failed()) {
              ar.cause().printStackTrace();
              return;
            }
            final AsyncFile file = ar.result();
            final Pump pump = Pump.createPump(req, file);
            final long start = System.currentTimeMillis();
            req.endHandler(new VoidHandler() {
              public void handle() {
                file.close(new AsyncResultHandler<Void>() {
                  public void handle(AsyncResult<Void> ar) {
                    if (ar.succeeded()) {
                      req.response().end();
                      long end = System.currentTimeMillis();
                      System.out.println("Uploaded " + pump.bytesPumped() + " bytes to " + filename + " in " + (end - start) + " ms");
                    } else {
                      ar.cause().printStackTrace(System.err);
                    }
                  }
                });
              }
            });
            pump.start();
            req.resume();
          }
        });
      }
    }).listen(8080);
View Full Code Here


      // req.setChunked(true);

      vertx.fileSystem().open(filename, new AsyncResultHandler<AsyncFile>() {
        public void handle(AsyncResult<AsyncFile> ar) {
          final AsyncFile file = ar.result();
          Pump pump = Pump.createPump(file, req);
          pump.start();

          file.endHandler(new VoidHandler() {
            public void handle() {

              file.close(new AsyncResultHandler<Void>() {
View Full Code Here

        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");
                    } else {
                      ar.exception.printStackTrace(System.err);
                    }
                  }
                });
              }
            });
            pump.start();
            req.resume();
          }
        });
      }
    }).listen(8080);
View Full Code Here

    // req.setChunked(true);

    vertx.fileSystem().open(filename, new AsyncResultHandler<AsyncFile>() {
      public void handle(AsyncResult<AsyncFile> ar) {
        final AsyncFile file = ar.result;
        Pump pump = Pump.createPump(file.getReadStream(), req);
        pump.start();

        file.getReadStream().endHandler(new SimpleHandler() {
          public void handle() {

            file.close(new AsyncResultHandler<Void>() {
View Full Code Here

        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");
                    } else {
                      ar.exception.printStackTrace(System.err);
                    }
                  }
                });
              }
            });
            pump.start();
            req.resume();
          }
        });
      }
    }).listen(8080);
View Full Code Here

    // req.setChunked(true);

    vertx.fileSystem().open(filename, new AsyncResultHandler<AsyncFile>() {
      public void handle(AsyncResult<AsyncFile> ar) {
        final AsyncFile file = ar.result;
        Pump pump = Pump.createPump(file.getReadStream(), req);
        pump.start();

        file.getReadStream().endHandler(new SimpleHandler() {
          public void handle() {

            file.close(new AsyncResultHandler<Void>() {
View Full Code Here

    vertx.fileSystem().open(filename, new AsyncResultHandler<AsyncFile>() {
      public void handle(final AsyncResult<AsyncFile> ar) {
        if (ar.succeeded()) {
          file =  ar.result();

          Pump p = Pump.createPump(DefaultHttpServerFileUpload.this, ar.result());
          p.start();

          resume();
        } else {
          notifyExceptionHandler(ar.cause());
        }
View Full Code Here

TOP

Related Classes of org.vertx.java.core.streams.Pump

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.