Storage and delivery guarantees | laravel-medialibrary-rust | Spatie       

 SPATIE  

laravel-medialibrary-rust
=========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-medialibrary-rust](https://spatie.be/docs/laravel-medialibrary-rust/v1)  Storage and delivery guarantees

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-medialibrary-rust/v1) 

  Storage and delivery guarantees    
- [ Introduction ](https://spatie.be/docs/laravel-medialibrary-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-medialibrary-rust/v1/support-us)
- [ Installation and setup ](https://spatie.be/docs/laravel-medialibrary-rust/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-medialibrary-rust/v1/questions-issues)
- [ Requirements ](https://spatie.be/docs/laravel-medialibrary-rust/v1/requirements)
- [ Upgrading ](https://spatie.be/docs/laravel-medialibrary-rust/v1/upgrading)
- [ Changelog ](https://spatie.be/docs/laravel-medialibrary-rust/v1/changelog)
- [ Storage and delivery guarantees ](https://spatie.be/docs/laravel-medialibrary-rust/v1/storage-and-delivery)
- [ Troubleshooting ](https://spatie.be/docs/laravel-medialibrary-rust/v1/troubleshooting)
- [ Temporary uploads and form components ](https://spatie.be/docs/laravel-medialibrary-rust/v1/temporary-uploads)
- [ Testing ](https://spatie.be/docs/laravel-medialibrary-rust/v1/testing)
- [ About us ](https://spatie.be/docs/laravel-medialibrary-rust/v1/about-us)

Basic usage
-----------

- [ Preparing your model ](https://spatie.be/docs/laravel-medialibrary-rust/v1/basic-usage/preparing-your-model)
- [ Associating files ](https://spatie.be/docs/laravel-medialibrary-rust/v1/basic-usage/associating-files)
- [ Retrieving media ](https://spatie.be/docs/laravel-medialibrary-rust/v1/basic-usage/retrieving-media)

Working with media collections
------------------------------

- [ Simple media collections ](https://spatie.be/docs/laravel-medialibrary-rust/v1/working-with-media-collections/simple-media-collections)
- [ Defining media collections ](https://spatie.be/docs/laravel-medialibrary-rust/v1/working-with-media-collections/defining-media-collections)

Converting images
-----------------

- [ Defining conversions ](https://spatie.be/docs/laravel-medialibrary-rust/v1/converting-images/defining-conversions)
- [ Retrieving converted images ](https://spatie.be/docs/laravel-medialibrary-rust/v1/converting-images/retrieving-converted-images)
- [ Optimizing converted images ](https://spatie.be/docs/laravel-medialibrary-rust/v1/converting-images/optimizing-converted-images)
- [ Regenerating images ](https://spatie.be/docs/laravel-medialibrary-rust/v1/converting-images/regenerating-images)

Responsive images
-----------------

- [ Getting started with responsive images ](https://spatie.be/docs/laravel-medialibrary-rust/v1/responsive-images/getting-started-with-responsive-images)
- [ Using your own width calculator ](https://spatie.be/docs/laravel-medialibrary-rust/v1/responsive-images/using-your-own-width-calculator)
- [ Customizing the rendered HTML ](https://spatie.be/docs/laravel-medialibrary-rust/v1/responsive-images/customizing-the-rendered-html)
- [ Generating your own tiny placeholder ](https://spatie.be/docs/laravel-medialibrary-rust/v1/responsive-images/generating-your-own-tiny-placeholder)
- [ Responsive images demo ](https://spatie.be/docs/laravel-medialibrary-rust/v1/responsive-images/demo)

Converting other file types
---------------------------

- [ Using image generators ](https://spatie.be/docs/laravel-medialibrary-rust/v1/converting-other-file-types/using-image-generators)
- [ Creating a custom image generator ](https://spatie.be/docs/laravel-medialibrary-rust/v1/converting-other-file-types/creating-a-custom-image-generator)

Downloading media
-----------------

- [ Downloading a single file ](https://spatie.be/docs/laravel-medialibrary-rust/v1/downloading-media/downloading-a-single-file)
- [ Downloading multiple files ](https://spatie.be/docs/laravel-medialibrary-rust/v1/downloading-media/downloading-multiple-files)

Advanced usage
--------------

- [ Working with multiple filesystems ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/working-with-multiple-filesystems)
- [ Using custom properties ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/using-custom-properties)
- [ Storing media specific manipulations ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/storing-media-specific-manipulations)
- [ Using your own model ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/using-your-own-model)
- [ Outputting media ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/outputting-media)
- [ Rendering media ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/rendering-media)
- [ Using a custom directory structure ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/using-a-custom-directory-structure)
- [ Using a custom file removal strategy ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/using-a-custom-file-removal-strategy)
- [ Ordering media ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/ordering-media)
- [ Using a custom media downloader ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/using-a-custom-media-downloader)
- [ Moving media ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/moving-media)
- [ Consuming events ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/consuming-events)
- [ Attaching media in mails ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/attaching-media-in-mails)
- [ Generating custom URLs ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/generating-custom-urls)
- [ Filesystem behavior ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/overriding-the-default-filesystem-behaviour)
- [ Naming generated files ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/naming-files)
- [ Disable CDN ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/disable-cdn)
- [ Customising database connections ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/customising-database-connections)
- [ Maintenance and workers ](https://spatie.be/docs/laravel-medialibrary-rust/v1/advanced-usage/maintenance)

API
---

- [ Adding files ](https://spatie.be/docs/laravel-medialibrary-rust/v1/api/adding-files)
- [ Defining conversions ](https://spatie.be/docs/laravel-medialibrary-rust/v1/api/defining-conversions)

 Storage and delivery guarantees
===============================

###  On this page 

1. [ Resource limits ](#content-resource-limits)
2. [ Paths, URLs and HTML ](#content-paths-urls-and-html)
3. [ Transactions and retries ](#content-transactions-and-retries)
4. [ Handling errors ](#content-handling-errors)
5. [ Application integration ](#content-application-integration)

Resource limits
-----------------------------------------------------------------------------------------------------

- File, stream, URL and base64 ingestion spool to private temporary files and use native disk streaming writes.
- Byte/string inputs, disk-to-disk ingestion, copy/move and `download` buffer at most the configured per-file limit.
- ZIP sources spool to temporary files before output. ZIP responses use bounded producer queues; metadata and central directories scale with entry count.
- Raster transforms require decoded image memory. Limits are 32,768 pixels per axis, 64 million pixels and 256 MiB decoding allocation. Native output reads stop at 256 MiB plus one byte. These are not OS sandbox or process-wide memory limits.

<a id="paths-urls-and-html"></a>

Paths, URLs and HTML
------------------------------------------------------------------------------------------------------------------

- Keys reject traversal, absolute paths, backslashes, colons and control characters. Filename strategies cannot return directories.
- Persisted paths continue to work after changing strategies. Originals include a UUID below the generated directory; derivative attempts have unique keys so rollback ID reuse and stale workers cannot overwrite another file.
- URLs and temporary URLs come from the configured disk. Local/private disks may not support signed URLs. Enable the framework's S3 feature and configure its backend for S3; cloud service behavior is not qualified by these tests.
- The HTTP downloader verifies TLS, uses a 30-second timeout, accepts only HTTP(S) without credentials, and caps bytes. It does not enforce an SSRF allowlist. Supply an application downloader for untrusted URLs.
- HTML output escapes values and rejects event handlers, reserved attributes and inline styles. Placeholder URIs must be base64 raster images. ZIP paths reject traversal.

<a id="transactions-and-retries"></a>

Transactions and retries
--------------------------------------------------------------------------------------------------------------------------------

- Media operations use native transactions and nested savepoints. Updates compare revisions; concurrent changes fail with `Error::Conflict` rather than overwriting another result. The worker retries failed jobs; applications must retry their own concurrent operations explicitly.
- Queue dispatch and ordinary event listeners wait for commit and are discarded on rollback. This is not an atomic SQL outbox. A process crash between commit and queue push can lose work. Reconcile or regenerate durable media after a dispatch failure.
- Deleting a media row queues retryable file cleanup. Run `queue:work --queue=media`; files remain until the worker removes them. Owner deletion hooks must run inside the owner's transaction. Native soft deletes are unavailable.
- SQL and disks are not atomic. Rollback and interrupted transforms can leave unreferenced files. Successful replacements clean up previous derivatives after commit; interrupted attempts may still need a sweep. Rename preserves the old original until commit.
- Cleanup deletes exact keys, not shared directories. Stop writers and workers, back up storage, and sweep only a prefix owned exclusively by the package.
- Immediate conversions run after commit. Their failure does not roll back the original; reload its ID before retrying. Deferred scheduling is unsupported and returns an error.

Handling errors
-----------------------------------------------------------------------------------------------------

- Match `Error::NotFound`, `Conflict`, `Invalid`, `Rejected`, `TooBig`, `Conversion` and `Download` for domain failures. These variants survive native transaction boundaries.
- Inspect `std::error::Error::source()` for framework and external-library causes. A native failure that cannot be extracted by value remains inside `Error::Framework`.
- Propagate failures with `?` from native handlers and jobs. Do not retry validation failures or treat after-commit failures as proof of rollback:

```
match library.delete_media(i64::MAX).await {
    Err(Error::NotFound(id)) => assert_eq!(id, i64::MAX),
    Err(error) => return Err(error.into()),
    Ok(()) => panic!("the example ID must not exist"),
}
```

<a id="application-integration"></a>

Application integration
-----------------------------------------------------------------------------------------------------------------------------

- Register `service_provider()` and use native configuration, disks, ORM, events and workers. Authentication, routing, tenant selection, supervision and mail transport belong to the app.
- Mail attachments refer to native storage descriptors. Framework 0.1.0 has no SMTP, Blade or translation services; the package does not emulate them.
- There is no automatic production-data importer. Back up and migrate rows/files explicitly when changing database or serialized-job schemas.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
