public static @NotNull Attachment createAttachment(@NotNull Path file, boolean isBinary) {
    try (InputStream inputStream = Files.newInputStream(file)) {
      return createAttachment(file.toString(), inputStream, Files.size(file), isBinary);
    }
    catch (IOException e) {
      LOG.warn("failed to create an attachment from " + file, e);
      return new Attachment(file.toString(), e);
    }
  }
public static @NotNull Attachment createAttachment(@NotNull Path file, boolean isBinary)