code: public CompletableFuture<InputStream> asInputStream(DiscordApi api) {
          CompletableFuture<InputStream> future = new CompletableFuture<>();
          try {
              if (fileAsBufferedImage != null) {
                  ByteArrayOutputStream os = new ByteArrayOutputStream();
                  ImageIO.write(fileAsBufferedImage, getFileType(), os);
                  future.complete(new ByteArrayInputStream(os.toByteArray()));
                  return future;
              }
              if (fileAsFile != null) {
                  future.complete(new FileInputStream(fileAsFile));
                  return future;
              }
              if (fileAsIcon != null || fileAsUrl != null) {
                  URL url = fileAsUrl == null ? fileAsIcon.getUrl() : fileAsUrl;
                  api.getThreadPool().getExecutorService().submit(() -> {
                      try {
                          logger.debug("Trying to download file from {}", url);
                          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                          conn.setRequestMethod("GET");
                          conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
                          conn.setRequestProperty("User-Agent", Javacord.USER_AGENT);
                          future.complete(conn.getInputStream());
                          logger.debug("Downloaded file from {} (content length: {})", url, conn.getContentLength());
                      } catch (Throwable t) {
                          future.completeExceptionally(t);
                      }
                  });
                  return future;
              }
              if (fileAsByteArray != null) {
                  future.complete(new ByteArrayInputStream(fileAsByteArray));
                  return future;
              }
              if (fileAsInputStream != null) {
                  future.complete(fileAsInputStream);
                  return future;
              }
              future.completeExceptionally(new IllegalStateException("No file variant is set"));
          } catch (Throwable t) {
              future.completeExceptionally(t);
          }
          return future;
      }
docs: Gets the input stream for the file.
  
  @param api The discord api instance.
  @return The input stream for the file.