Store, retrieve, and delete files across local, S3, and other disks with the Storage facade.
File Storage
use IlluminateSupportFacadesStorage;
// Store
Storage::put("file.txt", "contents");
Storage::disk("s3")->put("file.txt", "contents");
$path = $request->file("avatar")->store("avatars");
$path = $request->file("avatar")->store("avatars", "s3");
// Read
Storage::get("file.txt");
Storage::exists("file.txt");
Storage::size("file.txt");
Storage::lastModified("file.txt");
Storage::files("directory");
// Delete
Storage::delete("file.txt");
Storage::deleteDirectory("avatars");
// URLs
Storage::url("file.txt"); // public URL
Storage::temporaryUrl("file.txt", now()->addMinutes(5)); // S3 signed URL
// config/filesystems.php
"disks" => [
"s3" => [
"driver" => "s3",
"key" => env("AWS_ACCESS_KEY_ID"),
"secret" => env("AWS_SECRET_ACCESS_KEY"),
"region" => env("AWS_DEFAULT_REGION"),
"bucket" => env("AWS_BUCKET"),
],
]