file-upload-processor
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "file-upload-processor" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-defbe619fce0af366f987ef2eff5ee603e1979b667f782a9c38a76de5c6963b7. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
File upload processor: for building file upload features in web applications. Applicable when users mention "file upload", "image upload", "upload endpoint", "chunked upload", "presigned URL", "S3 upload", "file validation", or "receiving user files". Handles upload endpoints, file validation (type, size, magic bytes), cloud storage integration, and upload status tracking. For post-upload image/video processing, see media-transcoder.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Testing
- Not tested
Browse files
Frontmatter
name: file-upload-processor
description: >-
When the user needs to build file upload functionality for a web application.
Use when the user mentions "file upload," "image upload," "upload endpoint,"
"multipart upload," "presigned URL," "S3 upload," "file validation," "upload
to cloud storage," or "accept user files." Handles upload endpoints, file
validation (type, size, magic bytes), cloud storage integration, and upload
status tracking. For image/video processing after upload, see media-transcoder.
license: Apache-2.0
compatibility: "Node.js 18+, Python 3.9+"
metadata:
author: terminal-skills
version: "1.0.0"
category: development
tags: ["file-upload", "cloud-storage", "s3", "validation"]File Upload Processor
Overview
Builds secure file upload endpoints for web applications. Handles multipart form uploads, presigned URL generation for large files, file type validation via magic bytes (not just extensions), size limits, cloud storage integration (S3, GCS, R2), and upload status tracking. Produces production-ready code with streaming (no temp files on disk for small files).
Instructions
1. Choose Upload Strategy
Based on file size:
- Small files (< 10MB): Stream through server to storage. Simple, one request.
- Medium files (10-100MB): Server-side streaming with progress tracking.
- Large files (> 100MB): Presigned multipart upload — client uploads directly to S3.
2. File Validation
Always validate by magic bytes, never trust file extensions:
const MAGIC_BYTES = {
'image/jpeg': [0xFF, 0xD8, 0xFF],
'image/png': [0x89, 0x50, 0x4E, 0x47],
'image/webp': [0x52, 0x49, 0x46, 0x46], // + "WEBP" at offset 8
'application/pdf': [0x25, 0x50, 0x44, 0x46],
'video/mp4': null, // Check for "ftyp" at offset 4
'video/webm': [0x1A, 0x45, 0xDF, 0xA3],
};
function detectFileType(buffer: Buffer): string | null {
// Read first 12 bytes
// Match against known signatures
// Return MIME type or null if unknown
}
Additional validation:
- Check file size BEFORE reading the full body (Content-Length header)
- Set hard limits on multer/busboy to abort oversized uploads
- Scan for double extensions:
image.jpg.exe - Reject files with null bytes in filename
3. Storage Integration
// S3-compatible storage client
class StorageService {
async upload(key: string, stream: Readable, contentType: string): Promise<string>
async getPresignedUploadUrl(key: string, contentType: string, expiresIn: number): Promise<string>
async getPresignedDownloadUrl(key: string, expiresIn: number): Promise<string>
async initiateMultipartUpload(key: string): Promise<{ uploadId: string, parts: PresignedPart[] }>
async completeMultipartUpload(key: string, uploadId: string, parts: CompletedPart[]): Promise<void>
async delete(key: string): Promise<void>
}
Key naming convention: {type}/{userId}/{fileId}/{filename}
4. Upload Status Tracking
Database model:
files:
id: UUID
user_id: UUID
original_name: string
storage_key: string
mime_type: string
size_bytes: bigint
status: enum(uploading, uploaded, processing, processed, failed)
variants: jsonb (null until processed)
error: text (null unless failed)
created_at: timestamp
updated_at: timestamp
5. API Endpoints
POST /api/files/upload — Multipart form upload (< 100MB)
POST /api/files/presign — Get presigned URL for large file upload
POST /api/files/multipart/init — Start multipart upload (> 100MB)
POST /api/files/multipart/complete — Complete multipart upload
GET /api/files/:id/status — Get upload/processing status
GET /api/files/:id/download — Get presigned download URL
DELETE /api/files/:id — Soft delete file
Examples
Example 1: Express Upload Endpoint
Prompt: "Create a file upload endpoint for my Express app. Accept images and PDFs, store in S3."
Output: Upload route with multer streaming, magic-byte validation, S3 upload, database record creation, and error handling. Returns file ID for status polling.
Example 2: Presigned Upload for Large Videos
Prompt: "Users upload videos up to 2GB. I don't want them going through my server."
Output: Presigned URL generation endpoint, client-side upload code with progress tracking, multipart upload for files > 100MB, and a webhook endpoint to confirm upload completion and trigger processing.
Guidelines
- Stream, don't buffer — never load entire files into memory
- Validate magic bytes — file extensions lie, magic bytes don't
- Set upload limits at every layer — nginx, reverse proxy, and application
- Generate unique storage keys — include user ID and file ID, never use original filename as key
- Return immediately — upload ack should be instant, processing happens async
- Clean up on failure — if DB write fails, delete the S3 object; if S3 fails, don't create DB record
- Rate limit uploads — per user, per time window (e.g., 20 uploads per hour)
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决 Web 文件上传这一高频刚需场景
- 提供完整端到端方案,涵盖小文件流、大文件分块、预签名 URL、云存储集成、文件验证等
- 支持多种存储后端(S3、GCS、R2)和严格的文件验证机制(魔数验证)
Highlights
- 触发词覆盖全面且精准,包括"file upload"、"image upload"、"presigned URL"、"S3 upload"等
- 边界清晰,不易误触或漏触
Highlights
- 结构清晰,分 5 个明确阶段,每阶段有具体实现目标和代码示例
- 提供端到端示例(Express 上传端点、大视频预签名上传)
- frontmatter 完整,包含兼容性、许可证、元数据等
Highlights
- 使用主流可靠技术栈(multer/busboy、S3、GCS、R2)
- 覆盖主要异常处理(错误清理、速率限制、一致性保证)
- 提供具体参数配置和最佳实践建议
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.