Python + Transloadit
Upload and process a local file with pytransloadit, the maintained Python client for the Transloadit REST API.
Executable recipe
Build the integration
The script reads one file path from the command line, uploads it, resizes the image, waits for completion, and prints the Assembly ID.
- Create a virtual environment and install pytransloadit.
- Set TRANSLOADIT_KEY and TRANSLOADIT_SECRET in the process environment.
- Run python process_image.py path/to/photo.jpg.
Install
python -m venv .venv
source .venv/bin/activate
pip install pytransloaditprocess_image.py
import os
import sys
from transloadit import client
transloadit = client.Transloadit(
os.environ['TRANSLOADIT_KEY'],
os.environ['TRANSLOADIT_SECRET'],
)
assembly = transloadit.new_assembly()
with open(sys.argv[1], 'rb') as input_file:
assembly.add_file(input_file)
assembly.add_step('resize', '/image/resize', {
'width': 1200,
'height': 1200,
'resize_strategy': 'fit',
})
response = assembly.create(retries=5, wait=True)
print(response.data['assembly_id'])Authentication
- Read the Transloadit Auth Key and Auth Secret from server environment variables and pass both to the official Python SDK.
- The SDK signs requests when the secret is supplied; never commit either credential to source control.
- Use a fixed Template when application users choose files, or validate every dynamic Step before creating an Assembly.
Limitations and operational notes
- wait=True blocks the process until the Assembly finishes. For web workers and long-running media jobs, store the Assembly ID and observe completion asynchronously.
- The maintained SDK supports Python 3.9 and newer; verify your runtime before installing the current release.
- Retries can resubmit work after transport failures. Keep application-level idempotency and record the returned Assembly ID.
More integrations