Package org.vertx.java.core.file

Examples of org.vertx.java.core.file.AsyncFile


                  public void handle(AsyncResult<AsyncFile> result) {
                    if (result.failed()) {
                      new DefaultFutureResult<Void>(result.cause()).setHandler(doneHandler);
                    } else {
                      // Send a message to the node telling it we're going to upload the module.
                      final AsyncFile file = result.result();
                      JsonObject message = new JsonObject()
                          .putString("action", "upload");
                      vertx.eventBus().sendWithTimeout(address, message, DEFAULT_REPLY_TIMEOUT, new Handler<AsyncResult<Message<JsonObject>>>() {
                        @Override
                        public void handle(AsyncResult<Message<JsonObject>> result) {
View Full Code Here


          public void handle(AsyncResult<AsyncFile> ar) {
            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");
View Full Code Here

      // For a chunked upload you don't need to specify size, just do:
      // 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>() {
                public void handle(AsyncResult<Void> ar) {
                  if (ar.succeeded()) {
                    req.end();
                    System.out.println("Sent request");
                  } else {
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");
View Full Code Here

    // For a chunked upload you don't need to specify size, just do:
    // 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>() {
              public void handle(AsyncResult<Void> ar) {
                if (ar.exception == null) {
                  req.end();
                  System.out.println("Sent request");
                } else {
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");
View Full Code Here

    // For a chunked upload you don't need to specify size, just do:
    // 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>() {
              public void handle(AsyncResult<Void> ar) {
                if (ar.exception == null) {
                  req.end();
                  System.out.println("Sent request");
                } else {
View Full Code Here

TOP

Related Classes of org.vertx.java.core.file.AsyncFile

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.