Package com.jetdrone.vertx.yoke.core

Examples of com.jetdrone.vertx.yoke.core.YokeFileUpload


                    @Override
                    public void handle(final HttpServerFileUpload fileUpload) {
                        if (request.files() == null) {
                            request.setFiles(new HashMap<String, YokeFileUpload>());
                        }
                        final YokeFileUpload upload = new YokeFileUpload(vertx(), fileUpload, uploadDir);

                        // setup callbacks
                        fileUpload.exceptionHandler(new Handler<Throwable>() {
                            @Override
                            public void handle(Throwable throwable) {
                                next.handle(throwable);
                            }
                        });

                        // stream to the generated path
                        fileUpload.streamToFileSystem(upload.path());
                        // store a reference in the request
                        request.files().put(fileUpload.name(), upload);
                        // set up a callback to remove the file from the file system when the request completes
                        request.response().endHandler(new Handler<Void>() {
                            @Override
                            public void handle(Void event) {
                                if (upload.isTransient()) {
                                    upload.delete();
                                }
                            }
                        });
                    }
                });
View Full Code Here


            .post("/admin/import", new Middleware() {
                @Override
                public void handle(final YokeRequest request, final Handler<Object> next) {
                    final Config.Domain domain = request.get("domain");

                    final YokeFileUpload file = request.getFile("file");

                    fileSystem.readFile(file.path(), new AsyncResultHandler<Buffer>() {
                        @Override
                        public void handle(AsyncResult<Buffer> read) {
                            // delete the temp file
                            file.delete();
                            // parse
                            JsonArray json = new JsonArray(read.result().toString());
                            // iterate
                            new AsyncIterator<Object>(json) {
                                @Override
View Full Code Here

TOP

Related Classes of com.jetdrone.vertx.yoke.core.YokeFileUpload

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.