Developer CLI.

Integrate TempFileLink directly into your workflows. Because we offer a standard REST API for initiating transfers and accept raw PUT requests for uploads, you can use standard tools like `curl`.

Upload via Bash (curl)

upload.sh
#!/bin/bash
FILE="your_file.pdf"
FILE_SIZE=$(wc -c < "$FILE")

# 1. Request an upload URL
# WARNING: This example does NOT encrypt your file locally.
RESPONSE=$(curl -s -X POST https://www.tempfilelink.com/api/transfer/upload \
  -H "Content-Type: application/json" \
  -d '{
    "fileName": "'$FILE'",
    "fileSize": '$FILE_SIZE',
    "isEncrypted": false
  }')

UPLOAD_URL=$(echo $RESPONSE | grep -o '"uploadUrl":"[^"]*' | cut -d'"' -f4)
FILE_ID=$(echo $RESPONSE | grep -o '"fileId":"[^"]*' | cut -d'"' -f4)

# 2. Upload the file directly to R2
curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: application/octet-stream" \
  --data-binary @"$FILE"

echo "Success! Link: https://www.tempfilelink.com/f/$FILE_ID"

Security Note

The `curl` example above uploads files in the clear. For **Zero-Knowledge** privacy, you must encrypt files locally before uploading. Use the Python example below for built-in AES-256 GCM encryption.

Industrial Grade (Python + E2E Encryption)

secure_upload.py
import os
import requests
import base64
from cryptography.hazmat.primitives.ciphers.aead import AESGCM

FILE_PATH = "secret.docx"
BASE_URL = "https://www.tempfilelink.com"

# 1. Local Encryption (AES-256 GCM)
key = AESGCM.generate_key(bit_length=256)
aesgcm = AESGCM(key)
nonce = os.urandom(12)

with open(FILE_PATH, "rb") as f:
    data = f.read()

encrypted_data = aesgcm.encrypt(nonce, data, None)
payload = nonce + encrypted_data

# 2. Request Signed URL
response = requests.post(f"{BASE_URL}/api/transfer/upload", json={
    "fileName": os.path.basename(FILE_PATH),
    "fileSize": len(payload),
    "isEncrypted": true
}).json()

# 3. Secure PUT to R2
requests.put(response["uploadUrl"], data=payload, headers={
    "Content-Type": "application/octet-stream"
})

print(f"Success! Link: {BASE_URL}/f/{response['fileId']}#key={base64.urlsafe_b64encode(key).decode()}")