Registry / http-networking / tuspy
library1.1.0pypypi✓ verified 24d ago

tuspy is a Python client library for the tus resumable upload protocol (http://tus.io). It allows developers to reliably upload large files over HTTP, resuming interrupted uploads from where they left off. The current version is 1.1.0, and the library receives active maintenance with releases addressing bug fixes and minor feature enhancements.

pip install tuspy
INSTALL
IMPORT
SIG · TUSPY
T
tuspy
http-networkingpythonv1.1.0
Install
4.4s avg
Import
807ms
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.854s · 30.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.4s · import 0.760s · 32MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TusClient
from tusclient import client my_client = client.TusClient(...)
Uploader
from tusclient.uploader import Uploader
from tusclient import Uploader
Uploader is typically instantiated via a TusClient instance or imported from tusclient.uploader. Direct import from top-level tusclient package is incorrect.
AsyncUploader
from tusclient.asyncclient import AsyncUploader
from tusclient import AsyncUploader
AsyncUploader is part of the asyncclient module. Direct import from top-level tusclient package is incorrect.

This quickstart demonstrates how to initialize a `TusClient` and perform a synchronous file upload using the `Uploader`. It creates a dummy file if one doesn't exist and attempts to upload it to a specified tus server endpoint. Remember to set the `TUS_SERVER_ENDPOINT` environment variable or replace it directly.

import os from tusclient import client # Replace with your tus server endpoint TUS_ENDPOINT = os.environ.get('TUS_SERVER_ENDPOINT', 'http://master.tus.io/files/') FILE_TO_UPLOAD = 'path/to/your/local/file.txt' # Make sure this file exists # Create a dummy file for demonstration if it doesn't exist if not os.path.exists(FILE_TO_UPLOAD): with open(FILE_TO_UPLOAD, 'w') as f: f.write('This is a test file for tuspy upload.\n' * 100) print(f"Created dummy file: {FILE_TO_UPLOAD}") try: # 1. Create a TusClient instance my_client = client.TusClient(TUS_ENDPOINT) # 2. Create an Uploader instance # For synchronous uploads, use my_client.uploader() # For asynchronous uploads, use my_client.async_uploader() and await upload() uploader = my_client.uploader(FILE_TO_UPLOAD, chunk_size=2 * 1024 * 1024) # 2MB chunks # 3. Start the upload print(f"Attempting to upload {FILE_TO_UPLOAD} to {TUS_ENDPOINT}...") uploader.upload() print(f"Upload of {FILE_TO_UPLOAD} complete. Upload URL: {uploader.url}") except Exception as e: print(f"An error occurred during upload: {e}") print("Please ensure your TUS_SERVER_ENDPOINT is correct and accessible.") finally: # Clean up dummy file if os.path.exists(FILE_TO_UPLOAD): os.remove(FILE_TO_UPLOAD) print(f"Cleaned up dummy file: {FILE_TO_UPLOAD}")
Debug
Known issues
breakingPython 2 support was officially dropped in version 1.0.0. Projects still relying on Python 2 must use tuspy versions prior to 1.0.0.
fix
Upgrade to Python 3.5.3+ to use tuspy v1.0.0 and newer versions.
affects: <1.0.0
gotchaWhen working with `asyncio`, ensure you use `AsyncUploader` provided by `tusclient.asyncclient` and instantiate it via `client.async_uploader()`. The default `Uploader` is for synchronous operations.
fix
For async: `from tusclient.asyncclient import AsyncClient, AsyncUploader`; `async_client = AsyncClient(endpoint)`; `async_uploader = async_client.async_uploader(...)`; `await async_uploader.upload()`.
affects: >=1.0.0
gotchaIncorrect `chunk_size` can lead to performance issues or errors if the server has strict limits. Larger files benefit from larger `chunk_size` but must not exceed server-defined limits.
fix
Experiment with different `chunk_size` values. Default is 2MB (2 * 1024 * 1024 bytes). Consult your tus server documentation for optimal or maximum chunk sizes.
affects: All
gotchaEnsure the tus server endpoint (e.g., `http://master.tus.io/files/`) is correct and accessible. A common mistake is providing a file URL instead of the base tus endpoint for uploads.
fix
Verify the endpoint URL with your tus server's documentation. It should typically be a base path where new upload requests are initiated, not a specific file's URL.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tuspy'
The `tuspy` library is not installed in the current Python environment.
fix
pip install tuspy
requests.exceptions.ConnectionError
The tus server is unreachable, not running, or there's a network issue preventing the client from connecting.
fix
Ensure the tus server URL is correct, the server is running, and accessible from the client's network.
tus client failed: 404 Not Found
The provided `tus_url` does not point to a valid tus upload endpoint, the server rejected the request due to configuration, or the file stream/metadata caused a bad request.
fix
Verify the `tus_url` is correct and that the tus server is configured to handle the request properly; check server logs for specific details.

```python
from tuspy import client

tus_url = 'http://your-correct-tus-server/files/' # Ensure this is correct
my_client = client.TusClient(tus_url=tus_url)
# ... rest of your upload logic ...
```
requests.exceptions.SSLError
The client failed to verify the SSL certificate of the tus server, often due to self-signed certificates or misconfigured trust stores when connecting over HTTPS.
fix
Ensure the server's SSL certificate is valid and trusted by the client's system. Alternatively, for non-production environments, disable SSL verification by passing `verify_ssl=False` to `TusClient`.

```python
from tuspy import client

tus_url = 'https://your-tus-server/files/'
# For trusted certificates:
my_client = client.TusClient(tus_url=tus_url)

# For untrusted/self-signed certificates (use with caution in production):
# my_client = client.TusClient(tus_url=tus_url, verify_ssl=False)
```
Upgrade
Version history
1.1.0latest on PyPI · released Nov 29, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
tuspy — pip install tuspy · libregistry