code: public static File createRandomFile(MultipartFile file) {
          String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(file.getContentType().toString());
          if (StringUtils.isEmpty(extension)) {
              extension = MimeTypeMap.getFileExtensionFromUrl(file.getFilename());
          }
          String uuid = UUID.randomUUID().toString();
          return new File(App.getInstance().getRootDir(), uuid + "." + extension);
      }
docs: Create a random file based on mimeType.
  
  @param file file.
  
  @return file object.