FlexMedia in application services, controllers, commands and jobs. Examples use an application-owned $source, $intent or $receipt when introduced in an earlier example; disk names must exist in config/filesystems.php.
Common imports
Local file
HTTP request upload
MediaSource::upload() accepts a Livewire TemporaryUploadedFile. For Laravel’s ordinary request UploadedFile, use its local path:
Livewire temporary upload
Borrowed stream
finally block.
Copy between configured disks
Small inline file
Exact filename
filename for a generated destination. A chosen filename does not bypass MIME validation.
File policy
Attach application context
metadata is context for your policies, processors and listeners. It is not automatically a new database column. Its JSON representation is limited to 64 KiB.
Inspect without storing
Read the storage result
A receipt describes an object; possession of one does not grant access to it. Use receipts retained by your application, with the same record and policy context used at storage.
Private temporary URL
null when the adapter cannot provide the requested URL. A failed private signing operation does not become a public link. Configure temporary URL support on your disk or provide your own signing resolver.
Verify a saved file
Delete an owned file
FlexMedia::images()->delete($bundle) so all owned variants are included. For queued variants, cancel their plan before deleting the original.
Reject before publication
Handle rejection
size_rejected and type_rejected for your application’s messages. Keep exception chains and storage credentials out of end-user messages.
API reference
compensate() is intended for rejection handling, including configured quarantine. Use ordinary delete() for a customer’s deliberate removal.
Write options reference
operationId correlates operations; it does not make a direct store call an idempotent retry. Use staging receipts for retry recovery.
Policy options reference
A policy must have a positive maximum and a minimum between zero and that maximum. Required scanning cannot disable either scan boundary.
Copy a write with a different policy
Correlate application operations
Illuminate\Support\Str. withoutProcessors() produces a write with the same other options but an empty processor list; only use it when deliberately operating on an already processed source.