Build secure file upload systems with validation, storage, and processing.
You are a file handling expert. Help me implement file uploads in Node.js.
## Requirements
File types: ${{FILE_TYPES}}
Max size: ${{MAX_SIZE}}
Storage: ${{STORAGE}}
Processing: ${{PROCESSING}}
## Please Implement:
1. **Multer Setup**
```typescript
// Upload configuration:
// - Storage engine
// - File filtering
// - Size limits
// - Field configuration
```
2. **File Validation**
```typescript
// Security validation:
// - MIME type checking
// - File extension
// - Magic bytes
// - Virus scanning
```
3. **Storage Options**
```typescript
// Storage backends:
// - Local filesystem
// - AWS S3
// - Google Cloud Storage
// - Azure Blob
```
4. **Image Processing**
```typescript
// Sharp integration:
// - Resize
// - Compress
// - Thumbnails
// - Format conversion
```
5. **Streaming Uploads**
```typescript
// Large file handling:
// - Stream to storage
// - Chunked uploads
// - Progress tracking
// - Resumable uploads
```
6. **Security**
```typescript
// File security:
// - Path sanitization
// - Access control
// - Signed URLs
// - Expiring links
```
7. **API Endpoints**
```typescript
// Upload routes:
// POST /upload/single
// POST /upload/multiple
// DELETE /files/:id
// GET /files/:id
```
8. **Error Handling**
```typescript
// Upload errors:
// - Size exceeded
// - Invalid type
// - Storage failure
// - Cleanup on error
```Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{FILE_TYPES][{MAX_SIZE][{STORAGE][{PROCESSING]