Skip to main content

What are file contexts?

A file context is an upload pipeline. It defines the rules that every file must pass before being accepted into your system. Think of it as a named configuration for a specific type of upload. For example, a healthcare application might have:
  • patient_reports — PDFs and images up to 25MB, blank detection on, virus scanning on
  • profile_photos — JPEG and PNG only, max 5MB, no blank detection needed
  • insurance_claims — PDFs only, max 50MB, all validations enabled
Each context is identified by a unique context_key in snake_case (e.g., patient_reports). The key is immutable after creation.

Context configuration

Example: Creating a context

Rate limiting

Each context can have its own upload rate limit, defined by:
  • max_uploads — Maximum number of uploads allowed within the time window (1–10,000)
  • window_seconds — The time window in seconds (1–3,600)
If a rate limit is exceeded, the upload returns a 429 status with a clear error message.

Storage quotas

Set storage_quota_mb to cap the total storage used by files in a context. When the quota is reached, new uploads are rejected until files are deleted or the quota is increased. Check current usage via the storage_used_bytes field in context details.

Storage routing

By default, every context stores files in the tenant’s default storage bucket (an Amazon S3 bucket, Azure Blob container, or Google Cloud Storage bucket). Set storage_config_id to route a context to a specific storage bucket instead — useful for keeping different data types in separate buckets, regions, providers, or under separate credentials.
Only new uploads are affected — files already stored keep resolving to the bucket they were written to. Send an empty string to unbind the context and fall back to the default bucket. See Storage Buckets for how routing and fallback are resolved.

Context status

Contexts can be active or inactive. Inactive contexts reject all new uploads but still allow access to existing files.

Best practices

  • One context per use case. Don’t share a context between unrelated upload types. A medical records context should have different rules than a profile photo context.
  • Enable blank detection. Most upload pipelines benefit from rejecting blank files. It catches a surprisingly common class of data quality issues.
  • Set rate limits. Protect your system from upload floods, especially on public-facing endpoints.
  • Use storage quotas. Prevent runaway storage costs by setting reasonable limits per context.