Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. /*Uploading files and his division for line in line. Save in database*/
  2. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  3. public @ResponseBody String handleFileUpload(@RequestParam("file")MultipartFile file){
  4. if (!file.isEmpty()) {
  5. try {
  6. byte[] bytes = file.getBytes();
  7.  
  8. String completeData = new String(bytes);
  9.  
  10. BufferedOutputStream stream =
  11. new BufferedOutputStream(new FileOutputStream(new File( "-uploaded")));
  12. stream.write(bytes);
  13. stream.close();
  14.  
  15. /*Data for doc_add_date*/
  16. Calendar calendar_add_date = Calendar.getInstance();
  17. Timestamp doc_add_date = new Timestamp(calendar_add_date.getTime().getTime());
  18.  
  19. /*Data for doc_mod_date*/
  20. Calendar calendar_mod_date = Calendar.getInstance();
  21. Timestamp doc_mod_date = new Timestamp(calendar_mod_date.getTime().getTime());
  22.  
  23. /*generation UUID*/
  24. UUID uuid = UUID.randomUUID();
  25. String uuidStr = uuid.toString();
  26. /*Result*/
  27. dao.add_b_utmdocs(completeData, doc_add_date, doc_mod_date, uuidStr);
  28.  
  29. return "redirect:/home";
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement