Design file upload APIs with multipart handling, chunked uploads, and cloud storage integration.
You are a backend engineer specializing in file handling, streaming, and cloud storage integration.
## CONTEXT
I need to implement file upload functionality in my API.
**Requirements:**
- File Types: {{FILE_TYPES}}
- Max File Size: {{MAX_SIZE}}
- Storage: {{STORAGE}}
- Processing Needs: {{PROCESSING}}
## TASK
Design file upload API:
### 1. SIMPLE UPLOAD
```
POST /api/files
Content-Type: multipart/form-data
--boundary
Content-Disposition: form-data; name="file"; filename="doc.pdf"
Content-Type: application/pdf
[file content]
--boundary--
```
### 2. CHUNKED UPLOAD (Large Files)
```
# Initialize upload
POST /api/uploads/init
{ "filename": "video.mp4", "size": 1073741824, "mimeType": "video/mp4" }
Response: { "uploadId": "upload_123", "chunkSize": 5242880 }
# Upload chunks
PUT /api/uploads/upload_123/chunks/0
Content-Range: bytes 0-5242879/1073741824
# Complete upload
POST /api/uploads/upload_123/complete
```
### 3. PRESIGNED URLS (Direct to Cloud)
```json
POST /api/uploads/presigned
{ "filename": "image.jpg", "contentType": "image/jpeg" }
Response: {
"uploadUrl": "https://s3.../presigned",
"fileId": "file_123",
"expiresAt": "..."
}
```
### 4. VALIDATION
- File type validation
- Size limits
- Virus scanning
- Image dimension checks
### 5. PROGRESS TRACKING
WebSocket or polling for upload progress.
### 6. POST-PROCESSING
- Thumbnail generation
- Video transcoding
- Document parsingOr press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{FILE_TYPES][{MAX_SIZE][{STORAGE][{PROCESSING]{ "filename": "video.mp4", "size": 1073741824, "mimeType": "video/mp4" }{ "uploadId": "upload_123", "chunkSize": 5242880 }{ "filename": "image.jpg", "contentType": "image/jpeg" }{
"uploadUrl": "https://s3.../presigned",
"fileId": "file_123",
"expiresAt": "..."
}