Troubleshooting | laravel-medialibrary-go | Spatie       

 SPATIE  

laravel-medialibrary-go
=======================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-medialibrary-go](https://spatie.be/docs/laravel-medialibrary-go/v1)  Troubleshooting

 Version   v1      

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

  Troubleshooting    
- [ Introduction ](https://spatie.be/docs/laravel-medialibrary-go/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-medialibrary-go/v1/support-us)
- [ Base installation ](https://spatie.be/docs/laravel-medialibrary-go/v1/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-medialibrary-go/v1/questions-issues)
- [ Requirements ](https://spatie.be/docs/laravel-medialibrary-go/v1/requirements)
- [ Upgrading ](https://spatie.be/docs/laravel-medialibrary-go/v1/upgrading)
- [ Changelog ](https://spatie.be/docs/laravel-medialibrary-go/v1/changelog)
- [ Troubleshooting ](https://spatie.be/docs/laravel-medialibrary-go/v1/troubleshooting)
- [ Testing ](https://spatie.be/docs/laravel-medialibrary-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-medialibrary-go/v1/releasing)
- [ About us ](https://spatie.be/docs/laravel-medialibrary-go/v1/about-us)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

API
---

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

 Troubleshooting
===============

###  On this page 

1. [ Images return 404 on the public disk ](#content-images-return-404-on-the-public-disk)
2. [ A converted image is unavailable right after upload ](#content-a-converted-image-is-unavailable-right-after-upload)
3. [ Original files disappear after adding media ](#content-original-files-disappear-after-adding-media)
4. [ A transaction rolled back but a storage file remains ](#content-a-transaction-rolled-back-but-a-storage-file-remains)
5. [ PDF thumbnails fail ](#content-pdf-thumbnails-fail)
6. [ A custom model or job is not used ](#content-a-custom-model-or-job-is-not-used)
7. [ Queued work reads the wrong tenant ](#content-queued-work-reads-the-wrong-tenant)
8. [ Saving returns ErrConflict ](#content-saving-returns-errconflict)

Images return 404 on the public disk
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Check the disk's public mount and the application's URL configuration. A disk-relative key is not a public URL. Use `Library.URL` rather than concatenating a local filesystem path.

A converted image is unavailable right after upload
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Conversions are queued by default. Run the worker and reload the media snapshot. `URL` returns `ErrConversion` until a derivative is recorded. Use `AvailableConversion("thumb")` to fall back to the original, or configure synchronous execution when the result must be ready before returning.

Original files disappear after adding media
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

`AddMedia` and `AddMediaFromDisk` move the source by default. Chain `PreservingOriginal()` to keep it. Removal waits for the outermost transaction's commit.

A transaction rolled back but a storage file remains
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The filesystem does not participate in database rollback. Source files are preserved on rollback, but a completed destination write can remain unreferenced. See [cleaning up media](advanced-usage/cleaning-up-media) for dedicated-prefix orphan scans and their safety requirements.

PDF thumbnails fail
-----------------------------------------------------------------------------------------------------------------

Check that Ghostscript is installed and ImageMagick's `policy.xml` permits the PDF decoder. Do not loosen the policy globally without reviewing the security impact. A custom `PDFGenerator` can select another binary path and timeout.

A custom model or job is not used
-----------------------------------------------------------------------------------------------------------------------------------------------------------

Configure `Store` and matching `Migrations` explicitly. For jobs, both the prototype and factory must use your type. Registering another service with the same Go type does not override Laravel Go v0.1.0's first service registration.

Queued work reads the wrong tenant
--------------------------------------------------------------------------------------------------------------------------------------------------------------

Use `OnConnection("tenant")` before attaching or regenerating. The connection name then travels in the job payload. A request-only database context cannot automatically become worker state. Replacement jobs must honor `JobPayload.Connection`.

Saving returns ErrConflict
--------------------------------------------------------------------------------------------------------------------------------------

Another writer changed the media after your snapshot was read. Reload it and reapply the intended metadata change. Do not blindly retry a stale snapshot. Serialize regeneration, rename and deletion per media ID because database revision checks do not make storage writes atomic.

 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)
