Vertx FileUpload uploads file without extension

二次信任 提交于 2019-12-10 20:13:00

问题


I am using vertx-web and trying to upload file. Here is my code:

router.route().handler(BodyHandler.create().setUploadsDirectory("some/path/uploads"));
router.post("/api/upload").handler(routingContext -> {
    for(FileUpload f : routingContext.fileUploads()){
      System.out.println(f.fileName()); // logo.png
    }
    routingContext.response().end()
});

Above code, uploads file to the given path, but the uploaded file extension is missing.

File upload name: logo.png

File saved name: 45edd7b4-5287-4fba-927e-f256f4b09aea

I want the uploaded file extension and the content-type to remain as it is.


回答1:


You can't configure the BodyHandler to do this. The reason why it uses unique identifiers is to avoid name collisions.

You can move the file to another directory with a proper name.



来源:https://stackoverflow.com/questions/46189571/vertx-fileupload-uploads-file-without-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!