skip to content

Storage Facade

Laravel wraps Flysystem so local folders, S3 buckets and SFTP servers share one Storage API. Interviewers probe disk configuration and serving private files safely through temporary URLs.

on this pageshow

explore

questions

11

In Laravel, what do Storage::put(), get(), exists() and delete() return on success and failure, and what does a disk's throw option change?

level: juniorimportance: must knowfreq 56%

basics

~20 s

put(), delete(), copy() and move() return true or false; get() returns the contents or null; exists() returns a boolean. With a disk's throw option true, failures raise League\Flysystem exceptions such as UnableToWriteFile instead of returning false or null.

open as a page

In Laravel, how do FILESYSTEM_DISK and Storage::disk() pick the disk a Storage call writes to, and what does moving uploads to S3 require?

level: middleimportance: must knowfreq 60%

basics

~20 s

Storage calls without disk() go to the default disk, config filesystems.default, read from FILESYSTEM_DISK and falling back to local. Storage::disk('s3') picks a named disk. Moving to S3 needs the Flysystem S3 package, AWS credentials and bucket settings.

open as a page

In Laravel, when do you use Storage::url() versus Storage::temporaryUrl(), for example for private medical documents that should download for ten minutes?

level: middleimportance: must knowfreq 62%

basics

~10 s

Storage::url() builds a permanent, unsigned link that works only for publicly readable files. Storage::temporaryUrl($path, now()->addMinutes(10)) builds a signed link that expires, which suits private medical documents once the user has been authorized.

open as a page

In Laravel's s3 disk configuration, what do AWS_ENDPOINT, AWS_USE_PATH_STYLE_ENDPOINT and AWS_URL change when the disk points at an S3-compatible service?

level: middleimportance: should knowfreq 38%

basics

~20 s

AWS_ENDPOINT feeds the s3 disk's endpoint key, sending API calls to another S3-compatible host. AWS_USE_PATH_STYLE_ENDPOINT puts the bucket in the URL path instead of the hostname. AWS_URL sets the base URL Laravel uses for public file links.

open as a page

In Laravel, how do Storage::download() and Storage::response() differ, and what does each cost when the file sits on an S3 disk?

level: middleimportance: should knowfreq 42%

basics

~20 s

Both return a StreamedResponse that pipes the file through PHP: response() sends an inline disposition, download() an attachment. On S3 each first looks up the MIME type and size, then relays the object through your server.

open as a page

In Laravel 13, how would a read-through disk let a design-portfolio site move its uploads from the public disk to S3 without downtime, and what does it leave undone?

level: seniorimportance: should knowfreq 22%

basics

~20 s

A read-through disk (added in Laravel 13.26) reads the primary disk first, falls back to the old disk and copies the file forward. Writes and listings use the primary only, so unread files still need a backfill.

open as a page

In Laravel, what do scoped and read-only disks add on top of an existing disk, and when would you create a disk at runtime with Storage::build()?

level: seniorimportance: should knowfreq 28%

basics

~20 s

A scoped disk prefixes every path of another disk; a read-only disk (read-only => true) rejects writes. Storage::build() creates an uncached disk from a config array or a local root path, for settings known only at runtime.

open as a page

In Laravel, why can Storage::put($path, file_get_contents($tmp)) exhaust memory on a 2 GB scan archive, and how do putFile, putFileAs and streams avoid it?

level: seniorimportance: should knowfreq 40%

basics

~20 s

Passing a string means the whole 2 GB file sits in PHP memory. putFile and putFileAs open the file as a stream and write it chunk by chunk; put() with a resource, readStream()/writeStream() and copyToDisk() stream the same way.

open as a page

In Laravel, how does Storage::temporaryUploadUrl() let a browser upload a patient's scan straight to S3, and what must the app still do after the upload?

level: seniorimportance: should knowfreq 30%

basics

~20 s

temporaryUploadUrl($path, $expiresAt) returns an array with a signed url and the headers the browser must send; on S3 it is a presigned PutObject. The app still chooses the key, authorizes, and afterwards verifies the object and records it.

open as a page

In Laravel, what does Storage::append() actually do on an S3 disk, and why are append() and allFiles() expensive on remote disks?

level: seniorimportance: nice to knowfreq 18%

basics

~10 s

Storage::append() downloads the whole file, adds the new data and uploads everything again, so each call costs the full file and concurrent calls can lose lines. allFiles() lists every object recursively into one array.

open as a page