Example usage for io.vertx.core.file FileSystem moveBlocking

List of usage examples for io.vertx.core.file FileSystem moveBlocking

Introduction

In this page you can find the example usage for io.vertx.core.file FileSystem moveBlocking.

Prototype

@Fluent
FileSystem moveBlocking(String from, String to);

Source Link

Document

Blocking version of #move(String,String,Handler)

Usage

From source file:de.braintags.netrelay.controller.filemanager.elfinder.command.impl.UploadCommand.java

License:Open Source License

@Override
public void execute(ElFinderContext efContext, JsonObject json, Handler<AsyncResult<List<ITarget>>> handler) {
    String targetString = efContext.getParameter(ElFinderConstants.ELFINDER_PARAMETER_TARGET);
    ITarget parentDir = findTarget(efContext, targetString);
    Set<FileUpload> uploadedFiles = efContext.getRoutingContext().fileUploads();
    List<ITarget> added = new ArrayList<>();

    FileSystem fs = efContext.getRoutingContext().vertx().fileSystem();
    for (FileUpload upload : uploadedFiles) {
        String newFileName = FileSystemUtil.createUniqueName(fs, parentDir.getAbsolutePath(),
                upload.fileName());//from   w ww . j a  v  a 2  s .c o  m
        ITarget newFile = parentDir.createChildTarget(newFileName);
        fs.moveBlocking(upload.uploadedFileName(), newFile.getAbsolutePath());
        added.add(newFile);
    }

    json.put(ElFinderConstants.ELFINDER_JSON_RESPONSE_ADDED, buildJsonFilesArray(efContext, added));
    handler.handle(createFuture(added));
}

From source file:de.braintags.netrelay.controller.persistence.InsertAction.java

License:Open Source License

private String handleOneFile(FileSystem fs, FileUpload upload) {
    String uploadedFile = upload.uploadedFileName();
    String[] newDestination = examineNewDestination(fs, upload);
    fs.moveBlocking(uploadedFile, newDestination[0]);

    LOGGER.info(String.format(MOVE_MESSAGE, uploadedFile, newDestination[0]));
    return newDestination[1];
}