List<FileMeta> files = new LinkedList<FileMeta>();
// 1. Check request has multipart content
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
FileMeta temp = null;
// 2. If yes (it has multipart "files")
if(isMultipart){
// 2.1 instantiate Apache FileUpload classes
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
// 2.2 Parse the request
try {
// 2.3 Get all uploaded FileItem
List<FileItem> items = upload.parseRequest(request);
String twitter = "";
// 2.4 Go over each FileItem
for(FileItem item:items){
// 2.5 if FileItem is not of type "file"
if (item.isFormField()) {
// 2.6 Search for "twitter" parameter
if(item.getFieldName().equals("twitter"))
twitter = item.getString();
} else {
// 2.7 Create FileMeta object
temp = new FileMeta();
temp.setFileName(item.getName());
temp.setContent(item.getInputStream());
temp.setFileType(item.getContentType());
temp.setFileSize(item.getSize()/1024+ "Kb");
// 2.7 Add created FileMeta object to List<FileMeta> files
files.add(temp);
}