Hi guys,
I'm trying to do a simple File Upload using Vertx 3.0. I've
gone through the examples at [1] and [2] and essentially
trying a combination of both, as the requirement is to upload
the asset as well as send some metadata about the asset in the
same request itself. That is, I would like to support the
following HTML form
<form action="/form" ENCTYPE="multipart/form-data"
method="POST" name="wibble">
foo:<input type="text" name="foo"/><br>
bar:<input type="text" name="bar"/><br>
quux:<input type="text" name="quux"/><br>
choose a file to upload:<input type="file"
name="myfile"/><br>
<input type="submit"/>
</form>
The complete code for my Verticle is at [3]
As you can see from [3] What I don't know is how to specify
the request handlers in order to get both form attributes as
well as the uploaded file in a single Request Handler.
I also tried using Vertx-Web FileUpload by doing the
following
router.post("/form").handler(BodyHandler.create().setMergeFormAttributes(true));
.handler(routingContext -> {
Set<FileUpload> fileUploadSet =
routingContext.fileUploads();
Iterator<FileUpload> fileUploadIterator =
fileUploadSet.iterator();
while (fileUploadIterator.hasNext()){
FileUpload fileUpload =
fileUploadIterator.next();
// How to get actual file from this fileupload ?
}
});
But I dont know how to get the actual file from the
FileUpload [4] object. I could get the filename, contentType
but how to get the actual file that is being uploaded ?
I'm surely missing something really simple. Looking forward
to advice :)