private Response uploadStreamInChunks(
      long totalFileSize, String itemUploadUrl, String itemMimeType, InputStream inputStream)
      throws IOException, DestinationMemoryFullException {
    Response lastChunkResponse = null;
    StreamChunker streamChunker = new StreamChunker(MICROSOFT_UPLOAD_CHUNK_BYTE_SIZE, inputStream);
    Optional<DataChunk> nextChunk;
    while (true) {
      nextChunk = streamChunker.nextChunk();
      if (!nextChunk.isPresent()) break;
      lastChunkResponse = uploadChunk(nextChunk.get(), itemUploadUrl, totalFileSize, itemMimeType);
    }
    return lastChunkResponse;
  }
Depletes input stream, uploading a chunk of the stream at a time.
extensions/data-transfer/portability-data-transfer-microsoft/src/main/java/org/datatransferproject/transfer/microsoft/photos/MicrosoftPhotosImporter.java