Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cytetype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.19.0"
__version__ = "0.19.1"

import requests

Expand Down
10 changes: 7 additions & 3 deletions cytetype/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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.
Expand Down