Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chamals3n4/OpenATS/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Storage API provides file upload capabilities using Cloudflare R2 (S3-compatible object storage). It handles secure uploads for candidate resumes and company logos, with automatic file naming and public URL generation. Supported Operations:- Resume uploads (PDF format recommended)
- Company logo uploads (images)
- Automatic UUID-based file naming
- Public URL generation
- Content-type detection
Upload Resume
Upload a candidate resume file and receive a public URL.POST /upload/resume
- Content-Type:
multipart/form-data - Form field name:
file - Supported formats: PDF (recommended), DOC, DOCX, TXT
- Maximum file size: Determined by server configuration (typically 10MB)
| Field | Type | Required | Description |
|---|---|---|---|
file | binary | Yes | Resume file to upload |
| Field | Type | Description |
|---|---|---|
data.url | string | Public URL of the uploaded resume |
Upload Logo
Upload a company logo image and receive a public URL.POST /upload/logo
- Content-Type:
multipart/form-data - Form field name:
file - Supported formats: PNG, JPG, JPEG, SVG, WebP
- Maximum file size: Determined by server configuration (typically 5MB)
- Recommended dimensions: 400x400px or similar square/rectangular ratio
| Field | Type | Required | Description |
|---|---|---|---|
file | binary | Yes | Logo image file to upload |
| Field | Type | Description |
|---|---|---|
data.url | string | Public URL of the uploaded logo |
File Naming Convention
All uploaded files are automatically renamed using UUID v4 to ensure uniqueness and prevent conflicts: Pattern:- Original:
john_resume.pdf→ Stored as:resumes/550e8400-e29b-41d4-a716-446655440000.pdf - Original:
company-logo.png→ Stored as:logos/7c9e6679-7425-40de-944b-e07fc1f90ae7.png
- Prevents filename conflicts
- Maintains file extension for proper MIME type handling
- Obscures original filename for privacy
- Enables predictable URL structure
Storage Service Implementation
The storage service uses the AWS SDK for S3 to interact with Cloudflare R2: Key Features:Automatic Content-Type Detection
Automatic Content-Type Detection
The service automatically detects and sets the correct MIME type based on the file extension:
.pdf→application/pdf.png→image/png.jpg,.jpeg→image/jpeg.svg→image/svg+xml
UUID Generation
UUID Generation
Files are renamed with UUID v4 identifiers using Node.js
crypto.randomUUID():Public URL Construction
Public URL Construction
URLs are built using the configured R2 public domain:
Error Handling
Error Handling
Upload errors are logged with bucket information for debugging:
Environment Configuration
The storage service requires the following environment variables:| Variable | Description | Example |
|---|---|---|
R2_ENDPOINT | R2 storage endpoint URL | https://abc123.r2.cloudflarestorage.com |
R2_ACCESS_KEY_ID | R2 access key ID | your-access-key-id |
R2_SECRET_ACCESS_KEY | R2 secret access key | your-secret-access-key |
R2_BUCKET_NAME | Bucket name for storage | openats-storage |
R2_PUBLIC_URL | Public domain for file access | https://r2.openats.com |
Integration Examples
Complete Resume Upload Flow
Complete Logo Upload Flow
React Upload Component Example
Error Responses
Missing File (400):Security Considerations
Recommended Enhancements:- Virus Scanning: Integrate ClamAV or similar before storing files
- File Validation: Check file headers, not just extensions
- Rate Limiting: Prevent abuse with upload frequency limits
- Authentication: Require authentication for uploads (currently not enforced)
- Access Control: Implement private buckets with signed URLs for sensitive documents
Best Practices
For Resumes:- Prefer PDF format for consistent rendering
- Recommend file size under 5MB
- Validate that the file is actually a PDF (check magic bytes)
- Consider extracting text for search indexing
- Use PNG or SVG for best quality
- Recommend square dimensions (e.g., 400x400px)
- Optimize images before upload to reduce storage costs
- Consider generating multiple sizes (thumbnail, medium, large)
- Store file metadata (original name, size, upload date) in your database
- Implement soft delete for uploaded files
- Set up lifecycle policies to archive or delete old files
- Monitor storage usage and costs
- Implement CDN caching for frequently accessed files