0
0
Laravelframework~10 mins

S3 cloud storage integration in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the default filesystem disk to S3 in Laravel's config.

Laravel
'default' => '[1]',
Drag options to blanks, or click blank then click option'
As3
Blocal
Cftp
Dpublic
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' instead of 's3' will store files on the local server.
Using 'public' or 'ftp' are different storage drivers.
2fill in blank
medium

Complete the code to upload a file to the S3 disk using Laravel's Storage facade.

Laravel
Storage::disk('[1]')->put('folder/file.txt', $content);
Drag options to blanks, or click blank then click option'
Alocal
Bs3
Cpublic
Dftp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'local' will upload files to the local filesystem, not S3.
Forgetting to specify the disk defaults to local storage.
3fill in blank
hard

Fix the error in the code to get the URL of a file stored on S3.

Laravel
$url = Storage::disk('s3')->[1]('folder/file.txt');
Drag options to blanks, or click blank then click option'
Aget
Bpath
Curl
Ddownload
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' returns file contents, not the URL.
Using 'path' returns the local path, not a URL.
4fill in blank
hard

Fill both blanks to configure the S3 driver in Laravel's filesystems.php config.

Laravel
's3' => [
    'driver' => '[1]',
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION'),
    'bucket' => env('AWS_BUCKET'),
    'url' => env('[2]'),
],
Drag options to blanks, or click blank then click option'
As3
Blocal
CAWS_URL
DAPP_URL
Attempts:
3 left
💡 Hint
Common Mistakes
Setting driver to 'local' will not use S3.
Using 'APP_URL' instead of 'AWS_URL' for the S3 URL.
5fill in blank
hard

Fill the blanks to generate a temporary signed URL for a private S3 file.

Laravel
$url = Storage::disk('s3')->temporaryUrl('folder/file.txt', now()->add[1]([2]));
Drag options to blanks, or click blank then click option'
AMinutes
BHours
C30
D15
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'minutes' instead of 'hours' changes the URL validity period.
Forgetting to pass a number to addHours causes errors.