private MediaContainerResource convertMediaListToResource(
      Optional<String> albumId, GoogleMediaItem[] mediaItems, UUID jobId) throws IOException {
    List<PhotoModel> photos = new ArrayList<>(mediaItems.length);
    List<VideoModel> videos = new ArrayList<>(mediaItems.length);

    TempMediaData tempMediaData = null;
    InputStream stream = jobStore.getStream(jobId, createCacheKey()).getStream();
    if (stream != null) {
      tempMediaData = new ObjectMapper().readValue(stream, TempMediaData.class);
      stream.close();
    }

    ImmutableList.Builder<ErrorDetail> errors = ImmutableList.builder();
    for (GoogleMediaItem mediaItem : mediaItems) {
      boolean shouldUpload = albumId.isPresent();

      if (tempMediaData != null) {
        shouldUpload = shouldUpload || !tempMediaData.isContainedPhotoId(mediaItem.getId());
      }

      if (mediaItem.isPhoto()) {
        if (shouldUpload) {
          try {
            PhotoModel photoModel = GoogleMediaItem.convertToPhotoModel(albumId, mediaItem);
            photos.add(photoModel);

            monitor.debug(
                () -> String.format("%s: Google exporting photo: %s", jobId, photoModel.getDataId()));
          } catch(ParseException e) {
            monitor.info(() -> "Parse exception occurred while converting photo, skipping this item. "
                + "Failure message : %s ", e.getMessage());

            errors.add(GoogleErrorLogger.createErrorDetail(
                mediaItem.getId(), mediaItem.getFilename(), e, /* canSkip= */ true));
          }
        }
      } else if (mediaItem.isVideo()) {
        if (shouldUpload) {
          try {
            VideoModel videoModel = GoogleMediaItem.convertToVideoModel(albumId, mediaItem);
            videos.add(videoModel);

            monitor.debug(
                () -> String.format("%s: Google exporting video: %s", jobId, videoModel.getDataId()));
          } catch(ParseException e) {
            monitor.info(() -> "Parse exception occurred while converting video, skipping this item. "
                + "Failure message : %s ", e.getMessage());

            errors.add(GoogleErrorLogger.createErrorDetail(
                mediaItem.getId(), mediaItem.getFilename(), e, /* canSkip= */ true));
          }
        }
      }
    }

    // Log all the errors in 1 commit to DataStore
    GoogleErrorLogger.logFailedItemErrors(jobStore, jobId, errors.build());
    return new MediaContainerResource(null  /*albums*/, photos, videos);
  }
Method for storing a list of all photos that are already contained in albums
extensions/data-transfer/portability-data-transfer-google/src/main/java/org/datatransferproject/datatransfer/google/media/GoogleMediaExporter.java