laravel-filesystem-uploads
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFilesystem Uploads and URLs
文件系统上传与URL
Use the Storage facade consistently; abstract away the backend (local, S3, etc.).
统一使用Storage门面;抽象底层后端(本地、S3等)。
Commands
命令
$path = Storage::disk('public')->putFile('avatars', $request->file('avatar'));
// Temporary URLs (S3, etc.)
$url = Storage::disk('s3')->temporaryUrl($path, now()->addMinutes(10));
// Streams
return Storage::disk('backups')->download('db.sql.gz');$path = Storage::disk('public')->putFile('avatars', $request->file('avatar'));
// 临时URL(S3等)
$url = Storage::disk('s3')->temporaryUrl($path, now()->addMinutes(10));
// 流式传输
return Storage::disk('backups')->download('db.sql.gz');Patterns
模式
- Keep user uploads under a dedicated disk with explicit
visibility - Avoid assuming local paths; always go through Storage
- For public assets, run and serve via web server / CDN
storage:link - Validate mime/types and size limits at upload boundaries
- 将用户上传内容放在专用磁盘下,并设置明确的
visibility - 避免直接使用本地路径;始终通过Storage进行操作
- 对于公开资源,运行并通过Web服务器/CDN提供服务
storage:link - 在上传边界验证MIME类型和大小限制