file-upload-processor

文件上传处理器:用于为 Web 应用构建文件上传功能,适用于“文件上传/图片上传/上传端点/分块上传/预签名 URL/S3 上传/文件验证/接收用户文件”等场景。处理上传端点、文件验证(类型、大小、魔数)、云存储集成与上传状态跟踪。如需上传后对媒体处理,请参见 media-transcoder。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "file-upload-processor":https://skillpi.com/zh/skills/deepskill-defbe619fce0af366f987ef2eff5ee603e1979b667f782a9c38a76de5c6963b7。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

文件上传处理器:用于为 Web 应用构建文件上传功能,适用于“文件上传/图片上传/上传端点/分块上传/预签名 URL/S3 上传/文件验证/接收用户文件”等场景。处理上传端点、文件验证(类型、大小、魔数)、云存储集成与上传状态跟踪。如需上传后对媒体处理,请参见 media-transcoder。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
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)

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值92/100

亮点

  • 解决 Web 文件上传这一高频刚需场景
  • 提供完整端到端方案,涵盖小文件流、大文件分块、预签名 URL、云存储集成、文件验证等
  • 支持多种存储后端(S3、GCS、R2)和严格的文件验证机制(魔数验证)
触发精准95/100

亮点

  • 触发词覆盖全面且精准,包括"file upload"、"image upload"、"presigned URL"、"S3 upload"等
  • 边界清晰,不易误触或漏触
结构规范95/100

亮点

  • 结构清晰,分 5 个明确阶段,每阶段有具体实现目标和代码示例
  • 提供端到端示例(Express 上传端点、大视频预签名上传)
  • frontmatter 完整,包含兼容性、许可证、元数据等
执行可靠90/100

亮点

  • 使用主流可靠技术栈(multer/busboy、S3、GCS、R2)
  • 覆盖主要异常处理(错误清理、速率限制、一致性保证)
  • 提供具体参数配置和最佳实践建议
证据可验 (前四项均值)93/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。