Reputation: 377
I've created an XPage with a call to a Java class in the beforePageLoad
event that takes over.
In the Java class I want to receive one or multiple file uploads (through a HTML form with multiple file upload controls all with the same name file
).
This works:
Map parameters = request.getParameterMap();
UploadedFile file = (UploadedFile) parameters.get("file");
This does not work:
Map parameters = request.getParameterMap();
UploadedFile[] files = (UploadedFile[]) parameters.get("file");
So my questions is: How can I get to more than the first uploaded file from the Java class and loop through and process each of them?
Upvotes: 2
Views: 718
Reputation: 30960
Assuming, your Map parameters
contains all UploadedFiles then you can get them all with
for (Entry entry : parameters.entrySet()) {
System.out.println("parameter: " + entry.getKey());
if (entry.getValue() instanceof UploadedFile) {
UploadedFile file = entry.getValue();
// work with file
}
}
Upvotes: 2