Documentation Index
Fetch the complete documentation index at: https://fileguard.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
What is a File Context?
A file context is a configuration that defines rules for a specific category of file uploads. Think of it as a “folder type” with validation rules.
patient_reports
Medical reports: PDF only, max 10MB, virus scan enabled
profile_images
Profile pictures: JPG/PNG, max 5MB, image validation
invoices
Invoice uploads: PDF, max 15MB, blank file detection
data_imports
Bulk imports: CSV/XLSX, max 100MB, validation disabled
Context Configuration
| Setting | Description | Default |
|---|
context_key | URL-safe identifier (snake_case) | Required |
display_name | Human-readable name | Required |
allowed_extensions | List of allowed file types | [] (all allowed) |
max_file_size_mb | Maximum file size in MB | 10 |
reject_blank_files | Block empty/blank files | true |
reject_corrupt_files | Block corrupt files | true |
scan_for_viruses | ClamAV virus scanning | true |
upload_rate_limit | Rate limiting config | null (unlimited) |
storage_quota_mb | Storage cap in MB | null (unlimited) |
Creating a Context
curl -X POST "https://api.fileguard.io/api/v1/contexts" \
-H "Authorization: Bearer fg_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"context_key": "patient_reports",
"display_name": "Patient Reports",
"description": "Medical patient reports and documents",
"allowed_extensions": ["pdf"],
"max_file_size_mb": 10,
"reject_blank_files": true,
"reject_corrupt_files": true,
"scan_for_viruses": true
}'
Context Key Rules
- Must start with a letter
- Only lowercase letters, numbers, and underscores
- 1-100 characters
Valid examples:
patient_reports
kyc_documents
lab_results_2024
Invalid examples:
Patient-Reports (uppercase, hyphen)
123_files (starts with number)
my files (space)
Common Patterns
Healthcare
{
"context_key": "medical_records",
"display_name": "Medical Records",
"allowed_extensions": ["pdf"],
"max_file_size_mb": 10,
"reject_blank_files": true,
"reject_corrupt_files": true,
"scan_for_viruses": true
}
E-commerce
{
"context_key": "product_images",
"display_name": "Product Images",
"allowed_extensions": ["jpg", "jpeg", "png", "webp"],
"max_file_size_mb": 5,
"reject_blank_files": true,
"reject_corrupt_files": true
}
Finance
{
"context_key": "kyc_documents",
"display_name": "KYC Documents",
"allowed_extensions": ["pdf", "jpg", "png"],
"max_file_size_mb": 25,
"reject_blank_files": true,
"scan_for_viruses": true
}
Data Import (Relaxed)
{
"context_key": "bulk_imports",
"display_name": "Bulk Data Imports",
"allowed_extensions": ["csv", "xlsx"],
"max_file_size_mb": 100,
"reject_blank_files": false,
"reject_corrupt_files": false,
"scan_for_viruses": false
}
Rate Limiting
Limit uploads per time window:
{
"context_key": "user_uploads",
"upload_rate_limit": {
"max_uploads": 100,
"window_seconds": 60
}
}
This allows 100 uploads per minute for this context.
Storage Quotas
Limit total storage per context:
{
"context_key": "user_files",
"storage_quota_mb": 10240
}
This limits the context to 10 GB of storage.
Context Status
| Status | Description |
|---|
active | Accepts uploads |
inactive | Rejects all uploads |
Deactivate a context to stop accepting files without deleting configuration:
curl -X PATCH "https://api.fileguard.io/api/v1/contexts/patient_reports" \
-H "Authorization: Bearer fg_your_api_key" \
-H "Content-Type: application/json" \
-d '{"status": "inactive"}'