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

m615's avatar
Level 2

How do I set S3 public access on a file upload using Nova

I'm creating a MediaAsset model so that users of the Nova admin can attach images, 3d assets, pdfs, and whatever else they would like to a Product model.

I have my application set up so that Nova can upload to S3 and that works fine. What I can't figure out how to do is make sure that once the file is uploaded to S3 I need to set access to the file to the public so my Single Page app can pull in the asset and display things like image files or if it's a PDF the user will need to be able to click and download the file directly from S3.

By default, all these files are set to private when uploaded.

Here is what my fields section looks like in my Resource for MediaAsset model.

return [
            ID::make('id')->sortable()->hideFromDetail(),
            File::make('Media Asset', 'url')
                ->disk('s3')->prunable()
                ->storeOriginalName('filename')
                ->path('asset')->hideFromDetail(),
            Text::make('File Name', 'filename')->showOnDetail()->hideWhenCreating()->hideWhenUpdating(),
            Text::make('URL', 'url')->showOnDetail()->hideWhenCreating()->hideWhenUpdating(),
            BelongsTo::make('Product'),
        ];
0 likes
5 replies
Nakov's avatar

@m615 in this series https://laracasts.com/series/multitenancy-in-practice, Kevin is showing you how to allow public and private access to your s3 buckets. I think that you will need to setup the permissions on the Amazon side, nothing to do with Nova. You will just define two separate storage drivers, and use each one as you need.

m615's avatar
Level 2

Thanks. I actually watched that in order to get my uploads working and what I've ended up doing is adding the config to set everything public to my filesystems.php.

'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'),
            'visibility' => 'public'
        ],
m615's avatar
Level 2

What I would really like to be able to do from Nova is to allow the user to set an asset from public to private from the admin interface.

Nakov's avatar

What I would do in that case is create another disk in the filesystems.php file called: 's3_private' as an example, which will point to that bucket on S3, then in Nova you can display a radio button (toggle) which will allow the user to select which bucket they want to use. Then you will just need to use the correct disk based on which option was checked here:

File::make('Media Asset', 'url')->disk('s3') // or ->disk('s3_private')
1 like

Please or to participate in this conversation.