Advertisement
psi_mmobile

Untitled

Sep 30th, 2020
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. private String uploadFile(UploadedFile doc) {
  2. UploadedFile myDoc = doc;
  3. String path = null;
  4. if (myDoc == null) {
  5.  
  6. } else {
  7. InputStream inputStream = null;
  8. try {
  9. String dateAddition = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new java.util.Date());
  10. String ocLogos = BuildixxUtils.EXTERNAL_IMAGE_DIR + "operation_center_logos" + File.separator;
  11. String reportLogos = BuildixxUtils.EXTERNAL_IMAGE_DIR + "report_logos" + File.separator;
  12. if (this.ocLogo) {
  13. path = ocLogos + dateAddition + "_" + myDoc.getFilename();
  14. } else {
  15. DCIteratorBinding operationCenterIterator =
  16. ADFUtils.findIterator("OperationCenterForUserAdminCenterView1Iterator");
  17. Row currentOperationCenterRow = operationCenterIterator.getCurrentRow();
  18. path = reportLogos + (String)currentOperationCenterRow.getAttribute("GSymbol");
  19. }
  20. System.out.println(path + " PATH + FILENAME ");
  21. FileOutputStream out = new FileOutputStream(path);
  22. inputStream = myDoc.getInputStream();
  23. byte[] buffer = new byte[8192];
  24. int bytesRead = 0;
  25. while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
  26. out.write(buffer, 0, bytesRead);
  27. }
  28. out.flush();
  29. out.close();
  30. } catch (Exception ex) {
  31. log.error(ex.getMessage(), ex);
  32. } finally {
  33. try {
  34. inputStream.close();
  35. } catch (IOException ioex) {
  36. log.error(ioex.getMessage(), ioex);
  37. }
  38. }
  39. }
  40. return path;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement