code: protected String createFile(String dir, String fileName, byte[] content) {
          String baseName = FilenameUtils.getBaseName(fileName);
          String ext = FilenameUtils.getExtension(fileName);
          String downloadedFile = FileUtil.saveToFile(dir + baseName, ext, content);
          return linkToFile(downloadedFile);
      }
docs: Creates a file using the supplied content.
  @param dir directory to create file in.
  @param fileName name for file.
  @param content content to save.
  @return link to created file.