0
0
Laravelframework~20 mins

Filesystem configuration in Laravel - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Filesystem Configuration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
1:30remaining
What is the default disk used by Laravel's filesystem?
Given the default Laravel filesystem configuration, which disk will be used when calling Storage::disk() without any parameters?
A"public"
B"s3"
C"local"
D"ftp"
Attempts:
2 left
💡 Hint
Check the config/filesystems.php file for the default key.
📝 Syntax
intermediate
2:00remaining
Which configuration snippet correctly defines an S3 disk in Laravel?
Select the correct Laravel filesystem configuration array for an S3 disk.
A"s3" => ["driver" => "local", "key" => env("AWS_ACCESS_KEY_ID"), "secret" => env("AWS_SECRET_ACCESS_KEY"), "region" => env("AWS_DEFAULT_REGION"), "bucket" => env("AWS_BUCKET")]
B"s3" => ["driver" => "ftp", "key" => env("AWS_ACCESS_KEY_ID"), "secret" => env("AWS_SECRET_ACCESS_KEY"), "region" => env("AWS_DEFAULT_REGION"), "bucket" => env("AWS_BUCKET")]
C])"TEKCUB_SWA"(vne >= "tekcub" ,)"NOIGER_TLUAFED_SWA"(vne >= "noiger" ,)"YEK_SSECCA_TERCES_SWA"(vne >= "terces" ,)"DI_YEK_SSECCA_SWA"(vne >= "yek" ,"3s" >= "revird"[ >= "3s"
D"s3" => ["driver" => "s3", "key" => env("AWS_ACCESS_KEY_ID"), "secret" => env("AWS_SECRET_ACCESS_KEY"), "region" => env("AWS_DEFAULT_REGION"), "bucket" => env("AWS_BUCKET")]
Attempts:
2 left
💡 Hint
The driver for S3 must be exactly "s3" and keys must be named correctly.
🔧 Debug
advanced
2:30remaining
Why does this Laravel filesystem configuration cause an error?
Consider this snippet from config/filesystems.php:
"disks" => [
  "backup" => [
    "driver" => "local",
    "root" => storage_path("app/backups")
  ]
]
When trying to store a file using Storage::disk('backup')->put('file.txt', 'data');, an error occurs. What is the most likely cause?
AThe <code>storage/app/backups</code> directory does not exist and the local driver <code>put()</code> method does not automatically create directories.
BThe <code>root</code> path must be an absolute path string, not a function call.
CThe <code>driver</code> value "local" is invalid and should be "filesystem".
DThe disk name "backup" is reserved and cannot be used.
Attempts:
2 left
💡 Hint
Consider whether the put() method creates necessary directories if they don't exist.
state_output
advanced
1:30remaining
What is the output of this Laravel filesystem code snippet?
Given the following code snippet, what will be the output?
use Illuminate\Support\Facades\Storage;

Storage::fake('avatars');
Storage::disk('avatars')->put('user1.png', 'imagecontent');

return Storage::disk('avatars')->exists('user1.png') ? 'Found' : 'Not Found';
ASyntax error due to missing import
B"Found"
CRuntime error because fake disk is not writable
D"Not Found"
Attempts:
2 left
💡 Hint
The Storage::fake() method creates a temporary disk for testing.
🧠 Conceptual
expert
3:00remaining
How does Laravel determine the URL for a file stored on the "public" disk?
Laravel's "public" disk is configured with driver => "local" and root => storage_path('app/public'). How does Laravel generate the public URL for a file stored on this disk when calling Storage::disk('public')->url('file.jpg')?
AIt returns the URL by prefixing the file path with the value of the <code>APP_URL</code> environment variable plus "/storage/" because the <code>public/storage</code> folder is linked to <code>storage/app/public</code>.
BIt returns the absolute file system path on the server where the file is stored.
CIt returns a signed temporary URL valid for 5 minutes by default.
DIt returns the URL by prefixing the file path with "/public/" directly without considering environment variables.
Attempts:
2 left
💡 Hint
Think about the symbolic link created by php artisan storage:link.