nestjs-file-uploads
Secure file handling, Validation, and S3 streaming.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
File Upload Patterns
Priority: P0 (FOUNDATIONAL)
Secure file upload handling with validation and storage patterns.
-
Magic Bytes: NEVER trust
content-typeheader or file extension.-
Tool: Use
file-typeormmmagicto verify the actual buffer signature.
-
Tool: Use
-
Limits: Set strict
limits: { fileSize: 5000000 }(5MB) in Multer config to prevent DoS.
Streaming (Scalability)
-
Memory Warning: Default Multer
MemoryStoragecrashes servers with large files. -
Pattern: Use Streaming for any file > 10MB.
-
Library:
multer-s3(direct upload to bucket) orbusboy(raw stream processing). -
Architecture:
- Client requests Signed URL from API.
- Client uploads directly to S3/GCS (Bypassing API server completely).
- Pro Tip: This is the only way to scale file uploads infinitely.
-
Library:
Processing
- Async: Don't process images/videos in the HTTP Request.
-
Flow:
- Upload file.
- Push
FileUploadedEventto Queue (BullMQ). - Worker downloads, resizes/converts, and re-uploads.
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!