{"id":4403,"library":"tuspy","title":"Tuspy Client for Tus Resumable Upload Protocol","description":"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.","status":"active","version":"1.1.0","language":"en","source_language":"en","source_url":"https://github.com/tus/tus-py-client/","tags":["tus","upload","resumable-upload","client","http","file-transfer"],"install":[{"cmd":"pip install tuspy","lang":"bash","label":"Install tuspy"}],"dependencies":[],"imports":[{"symbol":"TusClient","correct":"from tusclient import client\nmy_client = client.TusClient(...)"},{"note":"Uploader is typically instantiated via a TusClient instance or imported from tusclient.uploader. Direct import from top-level tusclient package is incorrect.","wrong":"from tusclient import Uploader","symbol":"Uploader","correct":"from tusclient.uploader import Uploader"},{"note":"AsyncUploader is part of the asyncclient module. Direct import from top-level tusclient package is incorrect.","wrong":"from tusclient import AsyncUploader","symbol":"AsyncUploader","correct":"from tusclient.asyncclient import AsyncUploader"}],"quickstart":{"code":"import os\nfrom tusclient import client\n\n# Replace with your tus server endpoint\nTUS_ENDPOINT = os.environ.get('TUS_SERVER_ENDPOINT', 'http://master.tus.io/files/')\nFILE_TO_UPLOAD = 'path/to/your/local/file.txt' # Make sure this file exists\n\n# Create a dummy file for demonstration if it doesn't exist\nif not os.path.exists(FILE_TO_UPLOAD):\n    with open(FILE_TO_UPLOAD, 'w') as f:\n        f.write('This is a test file for tuspy upload.\\n' * 100)\n    print(f\"Created dummy file: {FILE_TO_UPLOAD}\")\n\n\ntry:\n    # 1. Create a TusClient instance\n    my_client = client.TusClient(TUS_ENDPOINT)\n\n    # 2. Create an Uploader instance\n    # For synchronous uploads, use my_client.uploader()\n    # For asynchronous uploads, use my_client.async_uploader() and await upload()\n    uploader = my_client.uploader(FILE_TO_UPLOAD, chunk_size=2 * 1024 * 1024) # 2MB chunks\n\n    # 3. Start the upload\n    print(f\"Attempting to upload {FILE_TO_UPLOAD} to {TUS_ENDPOINT}...\")\n    uploader.upload()\n    print(f\"Upload of {FILE_TO_UPLOAD} complete. Upload URL: {uploader.url}\")\n\nexcept Exception as e:\n    print(f\"An error occurred during upload: {e}\")\n    print(\"Please ensure your TUS_SERVER_ENDPOINT is correct and accessible.\")\nfinally:\n    # Clean up dummy file\n    if os.path.exists(FILE_TO_UPLOAD):\n        os.remove(FILE_TO_UPLOAD)\n        print(f\"Cleaned up dummy file: {FILE_TO_UPLOAD}\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade to Python 3.5.3+ to use tuspy v1.0.0 and newer versions.","message":"Python 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.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"For async: `from tusclient.asyncclient import AsyncClient, AsyncUploader`; `async_client = AsyncClient(endpoint)`; `async_uploader = async_client.async_uploader(...)`; `await async_uploader.upload()`.","message":"When 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Incorrect `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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"Ensure 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.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}