Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AdamAlicki's avatar

File Doest Not exist

I'm using the Spatie Media Library inside of Filament, latest version of Filament and Spatie Media Library.

Locally, I can upload files without issue. On production, I'm running into problems with the files not being found.

When I upload a file, I get the following error:

File `livewire-tmp/UqwC4HWFv9y3XvPBxfBOihXhyZKOp4-metaY2FyYm9uLnBuZw==-.png` does not exist

I've set the config/tailwind to:

'temporary_file_upload' => [
        'disk'            => 's3',
        // Example: 'local', 's3'              | Default: 'default'
        'rules'           => null,
        // Example: ['file', 'mimes:png,jpg']  | Default: ['required', 'file', 'max:12288'] (12MB)
        'directory'       => null,
        // Example: 'tmp'                      | Default: 'livewire-tmp'

All uploads go to an S3 bucket. I can see the files inside of the bucket, regardless of the uploader claiming there is an error.

I've tried numerous permissions on the storage/ folder. I've ensured the .env file has the appropriate variables, FILESYSTEM_DISK=s3. I've ensured the symlink to /public exists. I'm mostly out of ideas at this point.

0 likes
3 replies
LaryAI's avatar
Level 58

It seems like you're encountering an issue where the Spatie Media Library is unable to find the temporary file that Livewire has uploaded to your S3 bucket. This could be due to a number of reasons, including configuration issues or permission problems. Here are some steps you can take to troubleshoot and resolve the issue:

  1. Check Configuration: Ensure that your filesystems.php configuration file is set up correctly for the s3 disk. You should have something like this:
// config/filesystems.php

'disks' => [
    // ...

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
        'endpoint' => env('AWS_ENDPOINT'),
        // other S3 specific configurations...
    ],

    // ...
],
  1. Check .env Variables: Make sure that your .env file has the correct values for the S3 configuration:
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_DEFAULT_REGION=your_region
AWS_BUCKET=your_bucket_name
AWS_URL=your_optional_url
FILESYSTEM_DISK=s3
  1. Permissions: Verify that the IAM user whose credentials you are using has the necessary permissions to read and write to the specified S3 bucket.

  2. Temporary File Uploads: Since you're using Livewire for file uploads, ensure that the temporary file uploads are being stored in the correct disk. You might need to specify the disk and directory in your config/livewire.php:

// config/livewire.php

'temporary_file_upload' => [
    'disk' => 's3', // Make sure this is set to 's3'
    'directory' => 'livewire-tmp', // The directory within your S3 bucket
    'rules' => ['required', 'file', 'max:12288'],
],
  1. Symlinks: Since you're using S3, symlinks to the /public directory should not be relevant for file storage. However, make sure that your application is not relying on any symlinks that point to a local storage instead of S3.

  2. Clear Config Cache: If you've made changes to your configuration files, make sure to clear your config cache with the following command:

php artisan config:clear
  1. Debugging: Add logging to your file upload process to see if there are any errors during the upload or file handling process.

  2. File Paths: Ensure that the file paths used by Livewire and Spatie Media Library are consistent and correct. The error message suggests that there might be an issue with the file path or name.

If after checking all these points the issue still persists, you might want to look into the specific stack trace of the error to get more insight into what is going wrong. It could also be helpful to check the server logs for any additional error messages that could provide more context.

AdamAlicki's avatar

While the above AI post is helpful, and makes good points, all of those suggestions have been covered/addressed.

AdamAlicki's avatar
AdamAlicki
OP
Best Answer
Level 2

Potential Solution

Below is what worked for my case, and I may be missing something, but having the temporary files locally isn't a major issue for my startup.

In your config/livewire.php look for the following section:

    'temporary_file_upload' => [
        'disk'            => null,

        'rules'           => null,

        'directory'       => null,

        'middleware'      => null,

        'preview_mimes'   => [   // Supported file types for temporary pre-signed file URLs...
            'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
            'mov', 'avi', 'wmv', 'mp3', 'm4a',
            'jpg', 'jpeg', 'mpga', 'webp', 'wma',
        ],
        'max_upload_time' => 5,

    ],

I set disk to local as it was s3 prior. This allows me to upload photos without issues now.

1 like

Please or to participate in this conversation.