indexer.upload() call handles files up to a few gigabytes comfortably. For larger files, the SDK provides splitable uploads that automatically split the file into fragments, submit each fragment independently, and return a list of root hashes. The corresponding fragment downloads reassemble them back into a single file.
When to use splitable uploads
- Your file is larger than 4 GB (the default fragment size)
- You want to parallelize uploads across multiple batches
- You need per-fragment retry granularity
indexer.upload() — it’s simpler and atomic.
Splitable upload
Uploader.splitable_upload() splits the file, uploads each fragment, and returns a list of root hashes in order.
Return value
splitable_upload returns ({'txHashes': [...], 'rootHashes': [...]}, err). The lists preserve fragment order — index 0 is the first fragment, index 1 is the second, and so on.
Save the rootHashes list — you’ll need it to reassemble the file on download.
Options
| Key | Type | Default | Description |
|---|---|---|---|
account | LocalAccount | required | Signer for Flow contract transactions |
fragmentSize | int | 4 GB | Max bytes per fragment (rounded up to a power of 2) |
batchSize | int | 10 | Fragments uploaded per batch |
tags | bytes | b"\x00" | Per-fragment tag bytes |
finalityRequired | bool | True | Wait for on-chain finality |
expectedReplica | int | 1 | Replica count per fragment |
fragmentSize is always aligned up to the nearest power of 2 and clamped to the 256-byte chunk minimum. A value of 3 GB becomes 4 GB internally.Behavior for small files
Iffile.size() <= fragmentSize, splitable_upload falls back to a single upload_file call. The return shape is the same — rootHashes will just have one entry.
Download fragments
To retrieve a multi-fragment file, useDownloader.download_fragments() with the list of root hashes in their original order. The downloader pulls each fragment, writes it to a temp file, and concatenates them into the final output.
Unified download() API
Downloader.download() accepts either a single root hash or a list — it dispatches to download_file or download_fragments automatically:
End-to-end example
Troubleshooting
'Output file already exists'
'Output file already exists'
download_fragments refuses to overwrite existing files. Delete the target file first or choose a new path.A fragment upload fails mid-batch
A fragment upload fails mid-batch
splitable_upload returns the partial result — rootHashes will contain only the fragments that succeeded before the failure. You can retry the remaining fragments manually or re-run the whole upload (fragments already on the network will be deduplicated via skipTx).Fragment order mismatch during download
Fragment order mismatch during download
The download output is the byte-wise concatenation of fragments in the order you pass them. You must pass
rootHashes in the exact order splitable_upload returned them — mixing the order corrupts the reassembled file.Fragment propagation timing
Fragment propagation timing
Each fragment goes through the same 3–5 minute propagation window as a regular upload. For multi-fragment files, all fragments must propagate before download succeeds.
Next steps
Upload & download
The basic upload/download flow for normal-sized files.
Error handling
Exception hierarchy, retry logic, and error codes.