From ebf127398a390517b79e38ca922161e1ccbe3795 Mon Sep 17 00:00:00 2001 From: parashardhapola Date: Sat, 7 Mar 2026 18:59:39 +0100 Subject: [PATCH] Update version to 0.19.1 and improve file upload initiation - Bump package version to 0.19.1. - Modify the file upload initiation to include the file size in the request, enhancing the upload process. - Update validation logic to ensure the number of presigned URLs is at least equal to the expected chunk count, improving error handling during uploads. --- cytetype/__init__.py | 2 +- cytetype/api/client.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cytetype/__init__.py b/cytetype/__init__.py index 08c2bb0..6ed29cc 100644 --- a/cytetype/__init__.py +++ b/cytetype/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.19.0" +__version__ = "0.19.1" import requests diff --git a/cytetype/api/client.py b/cytetype/api/client.py index 6819b92..6cc178c 100644 --- a/cytetype/api/client.py +++ b/cytetype/api/client.py @@ -56,7 +56,11 @@ def _upload_file( transport = HTTPTransport(base_url, auth_token) # Step 1 – Initiate chunked upload - _, init_data = transport.post_empty(f"upload/{file_kind}/initiate", timeout=timeout) + _, init_data = transport.post_json( + f"upload/{file_kind}/initiate", + data={"file_size_bytes": size_bytes}, + timeout=timeout, + ) upload_id: str = init_data["upload_id"] chunk_size: int = init_data["chunk_size_bytes"] @@ -73,10 +77,10 @@ def _upload_file( r2_upload_id: str | None = init_data.get("r2_upload_id") use_r2 = presigned_urls is not None and r2_upload_id is not None - if use_r2 and len(presigned_urls) != n_chunks: # type: ignore[arg-type] + if use_r2 and len(presigned_urls) < n_chunks: # type: ignore[arg-type] raise ValueError( f"Server returned {len(presigned_urls)} presigned URLs " # type: ignore[arg-type] - f"but expected {n_chunks} (one per chunk)." + f"but need at least {n_chunks} (one per chunk)." ) # Step 2 – Upload chunks in parallel.