// Copy the stream of file data to a temporary file. NOTE: This is necessary even if the
// current field is a simple form-field because the call below to diskFileItem.getString()
// will fail otherwise.
DiskFileItem diskFileItem = (DiskFileItem) diskFileItemFactory.createItem(fieldName,
contentType, formField, fileName);
Streams.copy(fieldStream.openStream(), diskFileItem.getOutputStream(), true);
// If the current field is a simple form-field, then save the form field value in the map.
if (diskFileItem.isFormField()) {
String characterEncoding = clientDataRequest.getCharacterEncoding();
String requestParameterValue = null;