Guest User

Untitled

a guest
Feb 13th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. @Override
  2. public void parse(HttpServletRequest request, String saveDir) throws IOException{
  3.  
  4.     multipartRequest = WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class);
  5.  
  6.     if(multipartRequest == null){
  7.         LOG.warn("Unable to MultipartHttpServletRequest");
  8.         errors.add("Unable to MultipartHttpServletRequest");
  9.         return;
  10.     }
  11.  
  12.     multipartMap = multipartRequest.getMultiFileMap();
  13.     for(Entry<String, List<MultipartFile>> fileEntry : multipartMap.entrySet()){
  14.  
  15.         String fieldName = fileEntry.getKey();
  16.         for(MultipartFile file : fileEntry.getValue()){
  17.  
  18.             if(!file.isEmpty()){        //A conditional check is added here.
  19.                 File temp = File.createTempFile("upload", ".dat");
  20.                 file.transferTo(temp);
  21.                 multiFileMap.add(fieldName, temp);
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment