I have a code base which currently uploads file using Post and has enctype as multipart/form-data. Now I need to include some form items i.e. some parameters will also be pa
If isFormField
on FileItemStream
returns true it's a normal field. You can use openStream
and read the contents into a String.
Something like this:
FileItemStream item = iter.next();
if(item.isFormField()) {
// Normal field
String name = item.getFieldName();
String value = Streams.asString(item.openStream());
} else {
// File
}
Streams.asString
takes a second parameter which is the charset encoding to use, you might need to specify one that is suitable for your site.