Laravel Filesystem (dựa trên Flysystem) trừu tượng nhiều "disk" — local, public, s3... — cấu hình trong config/filesystems.php, và cùng một API Storage cho mọi disk.
Đổi từ local sang S3 không phải sửa code nghiệp vụ.
php
// $request->file('avatar') trả về UploadedFile
$path = $request->file('avatar')->store('avatars', 'public');
// => 'avatars/abc123.jpg' (tên random), URL: Storage::url($path)
$request->file('doc')->storeAs('docs', $customName, 's3'); // đặt tên + chọn disk- Validate trước khi lưu: rule
file,image,mimes:jpg,png,max:2048(đơn vị KB). - File cần truy cập qua URL: dùng disk
publicrồi chạyphp artisan storage:link(tạo symlinkstorage/app/public→public/storage). - Đọc/ghi tuỳ ý qua
Storage::disk('s3')->put(...),Storage::url(),Storage::delete(). - Không nhồi nội dung file vào cột DB — chỉ lưu đường dẫn.