private ItemImportResult<Integer> importPhoto(
      PhotoModel photoModel, UUID jobId, TokensAndUrlAuthData authData, String newAlbumId)
      throws IOException {
    InputStream inputStream;
    String imageDescription = photoModel.getDescription();
    String title = photoModel.getTitle();

    if (photoModel.isInTempStore()) {
      inputStream = jobStore.getStream(jobId, photoModel.getFetchableUrl()).getStream();
    } else if (photoModel.getFetchableUrl() != null) {
      inputStream = new URL(photoModel.getFetchableUrl()).openStream();
    } else {
      String errorMessage = "Can't get inputStream for a photo";
      monitor.severe(() -> errorMessage);
      return ItemImportResult.error(new IOException(errorMessage), null);
    }

    byte[] imageBytes = ByteStreams.toByteArray(inputStream);
    String imageData = Base64.getEncoder().encodeToString(imageBytes);

    Request.Builder requestBuilder = new Request.Builder().url(baseUrl);
    requestBuilder.header("token", authData.getAccessToken());

    FormBody.Builder builder =
        new FormBody.Builder().add("image", imageData).add("exporter", exportService);

    if (!Strings.isNullOrEmpty(newAlbumId)) {
      builder.add("album", newAlbumId);
    }

    if (!Strings.isNullOrEmpty(title)) {
      builder.add("title", title);
    }

    if (!Strings.isNullOrEmpty(imageDescription)) {
      builder.add("description", imageDescription);
    }
    FormBody formBody = builder.build();
    requestBuilder.post(formBody);

    try (Response response = client.newCall(requestBuilder.build()).execute()) {
      int code = response.code();
      // Though sometimes it returns error code for success requests
      Preconditions.checkArgument(
          code >= 200 && code <= 299,
          String.format(
              "Error occurred in request for %s, code: %s, message: %s",
              baseUrl, code, response.message()));

      if (photoModel.isInTempStore()) {
        jobStore.removeData(jobId, photoModel.getFetchableUrl());
      }
      return ItemImportResult.success(response.code(), (long) imageBytes.length);
    }
  }
Imports albums and photos to Daybook
extensions/data-transfer/portability-data-transfer-daybook/src/main/java/org/datatransferproject/transfer/daybook/photos/DaybookPhotosImporter.java