public void handle() {
try {
FileUpload upload = createFileUpload();
FileItemIterator iter = upload.getItemIterator(request);
while (iter.hasNext()) {
FileItemStream item = iter.next();
String name = item.getFieldName();
InputStream stream = item.openStream();
if (item.isFormField()) {
String value =
normalizeValue(Streams.asString(stream, request
.getCharacterEncoding()));
if (name.endsWith(ARRAY_SUFFIX)) {
String[] array = (String[]) request.getAttribute(name);
if (array == null) {
array = new String[0];
}
request.setAttribute(name, ArrayUtil.add(array, value));
} else {
request.setAttribute(name, value);
}
} else {
ByteArrayOutputStream baos =
new ByteArrayOutputStream(BYTE_ARRAY_SIZE);
Streams.copy(stream, baos, true);
byte[] data = baos.toByteArray();
FileItem value =
data.length > 0 ? new FileItem(item.getFileName(), item
.getContentType(), data) : null;
if (name.endsWith(ARRAY_SUFFIX)) {
FileItem[] array =
(FileItem[]) request.getAttribute(name);
if (array == null) {