Skip to main content

UploadThing adapter for files-sdk

Project description

files-sdk-uploadthing

UploadThing adapter for files-sdk. Sync and async variants over httpx, with locally-computed HMAC presigned URLs (ported from the upstream TypeScript SDK — no UT-side roundtrip for upload URL generation).

Install

uv add files-sdk files-sdk-uploadthing

Usage

from files_sdk import Files
from files_sdk_uploadthing import UploadThingAdapter

files = Files(adapter=UploadThingAdapter())   # reads UPLOADTHING_TOKEN
files.upload("users/123/avatar.png", b"...")
print(files.download("users/123/avatar.png").as_bytes())

Async:

from files_sdk_uploadthing import AsyncUploadThingAdapter

a = AsyncUploadThingAdapter()
await a.upload("users/123/avatar.png", b"...")

Auth

Set UPLOADTHING_TOKEN (the base64 JSON token from your UploadThing dashboard's API Keys page) in the environment, or pass token= explicitly. The decoded apiKey is the only secret sent — the token's appId and regions are extracted client-side.

Notes on the protocol mapping

The adapter's key: str maps to UploadThing's customId, so paths like users/123/avatar.png round-trip cleanly. The opaque per-file fileKey is generated client-side and never surfaced. A few protocol mismatches are handled transparently:

  • No prefix filter on listFiles — fetched pages are filtered in Python. The cursor is a stringified offset. Large accounts will see this.
  • No server-side copy — implemented as download + reupload.
  • No HEAD endpointhead() uses a one-byte ranged GET; the Content-Range header carries the true size.
  • CDN routing by customId doesn't resolve unicode keys — falls back to /v6/getFileUrl (one extra API roundtrip) when the direct fetch 404s.

Development

Live conformance tests require UPLOADTHING_TOKEN:

export UPLOADTHING_TOKEN=eyJh...
uv run pytest packages/files-sdk-uploadthing/

Without the token, only the offline tests (_token, _signing, _hash) run; the conformance suite skips.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

files_sdk_uploadthing-0.1.0a2.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

files_sdk_uploadthing-0.1.0a2-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file files_sdk_uploadthing-0.1.0a2.tar.gz.

File metadata

  • Download URL: files_sdk_uploadthing-0.1.0a2.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for files_sdk_uploadthing-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 3f8ea94ed85f9741ad1f452e84ed6e34aaf07780e933654f0ac75a3b16fe04c6
MD5 7a170f18b47a780e0d94ead99f9cdaf5
BLAKE2b-256 84cfe6f6c77ac0a66084e978883fc14c05e4c5c273b87912f3ec381ad7abfaf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for files_sdk_uploadthing-0.1.0a2.tar.gz:

Publisher: release.yml on menelsystems/files-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file files_sdk_uploadthing-0.1.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for files_sdk_uploadthing-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 4cde3aa99a594a0104b93340f6f47622818ffdc32fc9adeef2829a6ad15e63ad
MD5 5cecbac94acacd264ef0a5bd11d9d983
BLAKE2b-256 00ac1bf6a0d90d82f54d01f33cd053e52da1d08c5252de9b9342a1b80dd5f60e

See more details on using hashes here.

Provenance

The following attestation bundles were made for files_sdk_uploadthing-0.1.0a2-py3-none-any.whl:

Publisher: release.yml on menelsystems/files-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page