From d8c326d078a81e2aa720d0219d0be28490497206 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Fri, 1 Nov 2024 10:41:44 +0000 Subject: [PATCH] Add better export disk docs --- packages/actions/docs/01-installation.md | 8 ++++++++ .../actions/docs/07-prebuilt-actions/09-export.md | 12 +++++++++++- packages/panels/docs/01-installation.md | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/actions/docs/01-installation.md b/packages/actions/docs/01-installation.md index eb1bb23a4b..26b062bf55 100644 --- a/packages/actions/docs/01-installation.md +++ b/packages/actions/docs/01-installation.md @@ -147,6 +147,14 @@ Create a new `resources/views/components/layouts/app.blade.php` layout file for ``` +## Deploying to production + +### Using a production-ready storage disk + +Filament has a storage disk defined in the [configuration](#publishing-configuration), which by default is set to `public`. You can set the `FILAMENT_FILESYSTEM_DISK` environment variable to change this. + +The `public` disk, while great for easy local development, is not suitable for production. It does not support file visibility, so features of Filament such as [exports](prebuilt-actions/export) will create public files. In production, you need to use a production-ready disk such as `s3` with a private access policy, to prevent unauthorized access to the exported files. + ## Publishing configuration You can publish the package configuration using the following command (optional): diff --git a/packages/actions/docs/07-prebuilt-actions/09-export.md b/packages/actions/docs/07-prebuilt-actions/09-export.md index 451da3579c..6769d10fa4 100644 --- a/packages/actions/docs/07-prebuilt-actions/09-export.md +++ b/packages/actions/docs/07-prebuilt-actions/09-export.md @@ -4,6 +4,8 @@ title: Export action ## Overview +> Please note that this feature uses the Filament filesystem to store exported files. The disk used by the Filament filesystem is defined in the [configuration file](../installation#publishing-configuration). By default, the disk is set to `public` for easy local development, so when using Filament exports in production, please make sure that you use a production-ready disk such as `s3` with a private access policy. You may also consider [customizing the storage disk](#customizing-the-storage-disk) for exports only. + Filament v3.2 introduced a prebuilt action that is able to export rows to a CSV or XLSX file. When the trigger button is clicked, a modal asks for the columns that they want to export, and what they should be labeled. This feature uses [job batches](https://laravel.com/docs/queues#job-batching) and [database notifications](../../notifications/database-notifications#overview), so you need to publish those migrations from Laravel. Also, you need to publish the migrations for tables that Filament uses to store information about exports: ```bash @@ -378,7 +380,7 @@ public static function modifyQuery(Builder $query): Builder ### Customizing the storage disk -By default, exported files will be uploaded to the storage disk defined in the [configuration file](../installation#publishing-configuration). You can also set the `FILAMENT_FILESYSTEM_DISK` environment variable to change this. +By default, exported files will be uploaded to the storage disk defined in the [configuration file](../installation#publishing-configuration), which is `public` by default. You can set the `FILAMENT_FILESYSTEM_DISK` environment variable to change this. In production, you need to use a production-ready disk such as `s3` with a private access policy, to prevent unauthorized access to the exported files. If you want to use a different disk for a specific export, you can pass the disk name to the `disk()` method on the action: @@ -388,6 +390,14 @@ ExportAction::make() ->fileDisk('s3') ``` +You may set the disk for all export actions at once in the `boot()` method of a service provider such as `AppServiceProvider`: + +```php +use Filament\Actions\ExportAction; + +ExportAction::configureUsing(fn (ExportAction $action) => $action->fileDisk('s3')); +``` + Alternatively, you can override the `getFileDisk()` method on the exporter class, returning the name of the disk: ```php diff --git a/packages/panels/docs/01-installation.md b/packages/panels/docs/01-installation.md index e3e4fbfe00..1766d0903c 100644 --- a/packages/panels/docs/01-installation.md +++ b/packages/panels/docs/01-installation.md @@ -112,6 +112,12 @@ class User extends Authenticatable implements FilamentUser Learn more about [users](users). +### Using a production-ready storage disk + +Filament has a storage disk defined in the [configuration](#publishing-configuration), which by default is set to `public`. You can set the `FILAMENT_FILESYSTEM_DISK` environment variable to change this. + +The `public` disk, while great for easy local development, is not suitable for production. It does not support file visibility, so features of Filament such as [exports](../actions/prebuilt-actions/export) will create public files. In production, you need to use a production-ready disk such as `s3` with a private access policy, to prevent unauthorized access to the exported files. + ## Publishing configuration You can publish the Filament package configuration (if needed) using the following command: