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

jolora's avatar

Store Image files publicly in S3 compatible storage

Howdy.

I'm using an Image field in Nova for the first time and found that previews were not displaying.

I am using DigitalOcean Spaces with the S3 driver for the relevant disk. It seemed that files were uploaded with private permissions and so the preview URL was not accessible.

Currently I have a simple Image field:

Image::make('Image')
  ->disk('spaces')
  ->storeOriginalName('image_name')
  ->storeSize('image_size')
  ->store(new PublicUpload),

That is using an "invokable" class (PublicUpload) that looks like this:

<?php

namespace App\Nova;

use Illuminate\Http\Request;

class PublicUpload
{
    public function __invoke(Request $request, $model, $attribute, $requestAttribute, $disk, $storagePath)
    {
        $currentFile = $request->file($attribute);

        return [
            $attribute => $currentFile->storePublicly($storagePath)
        ];
    }
}

However, StorePublicly just doesn't seem to be doing its job the way I have this set up. The images upload to the Spaces storage but they are still set as "private".

I realise I could probably just create a route to alter the preview URL in Nova but I have no reason to store these files privately and I know this should be possible.

I'd appreciate any help or advice at all. Thanks in advance.

0 likes
0 replies

Please or to participate in this conversation.