Guest User

Untitled

a guest
Jan 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public void save(FileUploadEvent event) throws IOException {
  2. HashCode hashCode = null;
  3. HashCode hashCodeCompare = null;
  4. hashCode = Files.asByteSource(new File(event.toString())).hash(Hashing.murmur3_128(50));
  5. hashCodeCompare = Files.asByteSource(new File(FilePathOfFileToCompare)).hash(Hashing.murmur3_128(50));
  6. boolean hashTrueFalse;
  7. if(hashCode.equals(hashCodeCompare)) {
  8. System.out.println("true");
  9. } else{
  10. System.out.println("false");
  11. }
  12.  
  13. try (InputStream input = event.getFile().getInputstream()) {
  14. String imageName = generateFileName() + "." + fileExtensions(event.getFile().getFileName());
  15. String imageLink = PICTURE_DESTINATION + "\" + imageName;
  16.  
  17.  
  18. Picture picture = new Picture();
  19. picture.setPictureUrl(imageLink);
  20. pictureService.createOrUpdate(picture);
  21.  
  22. personForm.getCurrentPersonDTO().setPictureDTO(pictureMapper.toDTO(picture));
  23.  
  24.  
  25. } catch (IOException e) {
  26. e.printStackTrace();
  27. }
  28. }
Add Comment
Please, Sign In to add comment