- TUS Protocol: 1.0.0
This API implements the TUS resumable upload protocol, built with Hono and deployed on Cloudflare Workers. It provides a robust and reliable way to upload files with resume capability.
https://<your-worker>.workers.dev
Authentication is handled via Unkey. All requests must include a valid API key:
Authorization: Bearer <your-api-key>
Implemented using Upstash Rate Limit:
- Default: 100 requests/minute per IP
- Authenticated: 1000 requests/minute per API key
Creates a new upload resource.
POST /files
Tus-Resumable: 1.0.0
Upload-Length: [size]
Upload-Metadata: filename [base64_encoded_name],filetype [base64_encoded_type]
HTTP/1.1 201 Created
Location: https://<your-worker>.workers.dev/files/:id
Tus-Resumable: 1.0.0
Uploads a chunk of the file.
PATCH /files/:id
Tus-Resumable: 1.0.0
Content-Type: application/offset+octet-stream
Upload-Offset: [offset]
Content-Length: [chunk_size]
HTTP/1.1 204 No Content
Tus-Resumable: 1.0.0
Upload-Offset: [new_offset]
Get the current status of an upload.
HEAD /files/:id
Tus-Resumable: 1.0.0
HTTP/1.1 200 OK
Tus-Resumable: 1.0.0
Upload-Length: [total_size]
Upload-Offset: [current_offset]
Upload-Metadata: [metadata_string]
- creation
- creation-with-upload
- termination
- checksum
- expiration
Enables upload resource creation. Required for initiating uploads.
Allows including file data in the initial creation request.
Enables explicit upload termination.
DELETE /files/:id
Tus-Resumable: 1.0.0
Supports upload integrity verification.
PATCH /files/:id
Tus-Resumable: 1.0.0
Upload-Checksum: [algorithm] [base64_checksum]
Supported algorithms:
- sha1
- md5
Handles upload expiration.
Response includes:
Upload-Expires: [RFC7231_date_time]
201 Created
: Upload created successfully204 No Content
: Upload chunk processed successfully400 Bad Request
: Invalid request401 Unauthorized
: Invalid or missing API key403 Forbidden
: Operation not allowed404 Not Found
: Upload not found409 Conflict
: Upload offset mismatch410 Gone
: Upload expired or deleted413 Request Entity Too Large
: File too large415 Unsupported Media Type
: Invalid content type429 Too Many Requests
: Rate limit exceeded460 Checksum Mismatch
: Upload chunk checksum verification failed500 Server Error
: Internal server error
Files are stored in AWS S3:
- Region: [Your S3 Region]
- Bucket: [Your Bucket Name]
Redis caching via Upstash is implemented for:
- Upload metadata
- File status
- Authentication tokens
All error responses follow this format:
{
"error": {
"code": "ERROR_CODE",
"message": "Human readable message",
"details": {}
}
}
- Maximum file size: Defined by Tus-Max-Size header in OPTIONS response
- Chunk size: Recommended 5MB per PATCH request
- Expiration: Uploads expire after 24 hours if incomplete
- Supported file types: All types supported
- Metadata: Must be base64 encoded