Problems with chunked upload in Python API Client

Greetings.

I am having trouble with the Kaltura API Client. Specifically, with uploading large files in chunks. I’m using the latest version, Mac M1, Sonoma 14.5.

This has worked for years to upload a file all at once (and matches the documentation (https://developer.kaltura.com/workflows/Ingest_and_Upload_Media/Uploading_Media_Files):

with open(file, 'rb') as file_data:

    resume = False
    final_chunk = True
    resume_at = -1

    k_client.uploadToken.upload(upload_token_id, file_data, resume, final_chunk, resume_at)

However, this time I have some large files (largest are ~950MB), and the above code times out. I’ve followed the docs to send the files in chunks (e.g., uploadToken.upload - Kaltura VPaaS API Documentation) like this:

chunk_size = 10 * 1024 * 1024  # I've tried sizes from 2MB to 50MB
with open(file, 'rb') as file_data:
    chunk = file_data.read(chunk_size)
    resume = True
    final_chunk = False
    resume_at = 0

    while True:
        # final_chunk is False for all chunks except the last one
        final_chunk = len(chunk) < chunk_size
        k_client.uploadToken.upload(upload_token_id, chunk, resume, final_chunk, resume_at)
        resume_at += len(chunk)
        chunk = file_data.read(chunk_size)

    k_client.uploadToken.upload(uploadTokenId=upload_token_id, fileData=None, 
                                resume=False, finalChunk=True, resumeAt=-1)

I’ve tried several variations on the above, including wrapping each chunk as an io.BytesIO(chunk). Unfortunately, this gives me an error on the first chunk, and I’ve not been able to get past it:

KalturaException                          Traceback (most recent call last)
Cell In[28], line 17
     14     if file.split('.')[-1] in accessFormats:
     16         print(file)
---> 17         df = ingest_to_kaltura(file, df)
     19 # write out dictionary for later reference
     20 date = datetime.now().strftime("%Y%m%d-%H%M%S")

Cell In[27], line 70, in ingest_to_kaltura(file, df)
     68 first_chunk_bytes = file_content[:chunk_size]
     69 first_chunk_file = io.BytesIO(first_chunk_bytes)
---> 70 k_client.uploadToken.upload(upload_token_id, first_chunk_file, resume, finalChunk=False, resumeAt=resume_at)
     71 resume = True
     72 resume_at += len(first_chunk_bytes)

File ~/opt/anaconda3/lib/python3.8/site-packages/KalturaClient/Plugins/Core.py:68786, in KalturaUploadTokenService.upload(self, uploadTokenId, fileData, resume, finalChunk, resumeAt)
  68784 if self.client.isMultiRequest():
  68785     return self.client.getMultiRequestResult()
> 68786 resultNode = self.client.doQueue()
  68787 return KalturaObjectFactory.create(resultNode, 'KalturaUploadToken')

File ~/opt/anaconda3/lib/python3.8/site-packages/KalturaClient/Client.py:462, in KalturaClient.doQueue(self)
    459 self.log("Response headers  - server: [{0}], session: [{1}], proxy me: [{2}], proxy session: [{3}], connection: [{4}]".format(serverName, serverSession, proxyMe, proxySession, connection))
    461 # parse the result
--> 462 resultNode = self.parsePostResult(postResult)
    464 return resultNode

File ~/opt/anaconda3/lib/python3.8/site-packages/KalturaClient/Client.py:97, in retry_on_exception.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
     95         mtries -= 1
     96         mdelay *= backoff
---> 97 return func(*args, **kwargs)

File ~/opt/anaconda3/lib/python3.8/site-packages/KalturaClient/Client.py:422, in KalturaClient.parsePostResult(self, postResult)
    419     self.executionTime = getXmlNodeFloat(execTime)
    421 # Check for any error within resultNode
--> 422 self.throwExceptionIfError(resultNode)
    424 return resultNode

File ~/opt/anaconda3/lib/python3.8/site-packages/KalturaClient/Client.py:491, in KalturaClient.throwExceptionIfError(self, resultNode)
    489 if exceptionObj is None:
    490     return
--> 491 raise exceptionObj

KalturaException: Missing parameter "fileData" (MISSING_MANDATORY_PARAMETER) 

Any suggestions would be greatly appreciated!