fileUpload.setFileSizeMax(cfg.getFileUploadFileSizeMax());
}
try {
FileItemIterator it = fileUpload.getItemIterator(request);
while (it.hasNext()) {
FileItemStream fis = it.next();
if (fis.isFormField()) {
String s = Streams.asString(fis.openStream(), cfg.getCharset());
Object o = params.get(fis.getFieldName());
if (o == null) {
params.put(fis.getFieldName(), new String[]{s});
} else if (o instanceof String[]) {
String[] ss = (String[]) o;
String[] nss = new String[ss.length + 1];
System.arraycopy(ss, 0, nss, 0, ss.length);
nss[ss.length] = s;
params.put(fis.getFieldName(), nss);
}
} else if (!fis.getName().isEmpty()) {
FileExImpl fileEx = new FileExImpl(File.createTempFile("wfu", null));
Object o = params.get(fis.getFieldName());
if (o == null) {
params.put(fis.getFieldName(), new FileEx[]{fileEx});
} else if (o instanceof FileEx[]) {
FileEx[] ss = (FileEx[]) o;
FileEx[] nss = new FileEx[ss.length + 1];
System.arraycopy(ss, 0, nss, 0, ss.length);
nss[ss.length] = fileEx;
params.put(fis.getFieldName(), nss);
}
Streams.copy(fis.openStream(), new FileOutputStream(fileEx.getFile()), true);
fileEx.fileName = fis.getName();
fileEx.contentType = fis.getContentType();
}
}
} catch (FileUploadException e) {
if (action instanceof FileUploadExceptionAware) {
((FileUploadExceptionAware) action).setFileUploadException(e);