High-Throughput Data Streaming: Import & Export
GoFilament features a streaming data export and interactive column-mapping import engine designed for large datasets with minimal memory overhead ($O(\text{chunk size})$):
📤 High-Throughput Export:#
- Stream thousands of records directly to the browser or API clients without buffering whole tables in memory.
- Formats supported: CSV (
text/csv), TSV (text/tab-separated-values), Excel (.xlsx,format=xlsx) and JSON (application/json).columns=name,emaillimits the export to those columns. - Automatically exports configured table columns and labels, stripping HTML tags to output clean data.
- Row-level bulk export via
tables.ExportBulkAction(), or header actions withtables.ExportAction(). - Filter-aware: respects table search terms, active column filters, advanced search and selected record IDs. The web list’s Export buttons (CSV and Excel) download the list as it is filtered and sorted.
// Add Export to table header actions or bulk actions
table.HeaderActions(
tables.ExportAction[*Customer](),
tables.ImportAction[*Customer](),
).BulkActions(
tables.ExportBulkAction(),
)
📥 Import with preview:#
- Upload CSV, TSV or Excel (.xlsx) files (up to 10 MB) on the web (
/admin/{resource}/import), from the Flutter app (an Import button when the table hastables.ImportAction) or through the API. - Preview before saving: the file’s columns are matched to form fields (by name or label; change any of them), and every row is checked against the resource form. The preview shows the first rows with their problems and lists all rows that will be skipped; only then are the valid rows imported.
- Same rules as the create form: imported rows go through form validation,
CanCreateandOnCreate. Resources without a form keep the old behaviour (headers are normalized to field names). - Excel dates in date / datetime fields are converted from Excel day numbers.
- API:
POST /admin/api/resources/:slug/importwith afile(multipart),csvorfile_base64(JSON); adddry_run=1for the preview andmapping({"File header": "field"},""skips a column). Results list failed rows with field errors (rows).
✏️ Bulk edit#
res.BulkEditable("status", "owner_id") lets users set one of those form
fields to the same value on many selected rows: a Change Selected bulk
action on the web, a Change button in the Flutter selection bar, and
POST /admin/api/resources/:slug/bulk-update {ids, field, value}. The value
goes through the field’s validation; each record through CanEdit and the
trashed check, then OnUpdate with just that field (or OnBulkUpdate(fn)
once for all). Records that fail are reported, the others are changed. At
most 1000 records per bulk edit.
⏳ Background jobs (long exports and imports)#
panel.BackgroundJobs(filament.JobsConfig{Disk: "local"}) // storage disk for result files
- Web exports then run as a job: the user goes to a progress page
(
/admin/jobs/:id) and gets a notification with a Download link when it is ready. Imports confirmed on the preview page run as jobs too. - API:
GET .../export?background=1andPOST .../importwithbackground=1answer 202 with the job;GET /admin/api/jobs,/jobs/:idand/jobs/:id/download(only the user who started it). The Flutter app’s Export uses this when the panel has jobs. - Job state is kept in golaravel’s cache for
TTL(7 days; use a shared cache store with several instances), result files inDiron the disk. Jobs run in the process that started them (Concurrencyat once); a restart stops running jobs. Delete old files inDirwith a scheduled task.
🎭 Impersonation (“sign in as”)#
With panel.Sessions(...), an admin can sign in as another user to see the
panel as they do:
panel.Impersonation(filament.Impersonation{
CanImpersonate: func(ctx *filament.Context, target auth.Authenticatable) bool {
return isAdmin(ctx.User()) && !isAdmin(target)
},
OnImpersonate: func(ctx *filament.Context, admin, target auth.Authenticatable, leaving bool) { /* audit */ },
})
// a row action on the users table:
tables.Action[*User]("impersonate").Label("Sign in as").URL(func(u *User) string { return panel.ImpersonateURL(u.ID) })
A banner on every page shows who you are signed in as, with Return to my
account. While impersonating, the user’s profile, password and two-factor
settings cannot be changed, and you cannot impersonate someone else. Only the
web engine supports it (no API tokens are issued for other users).
filament.ImpersonatorID(ctx) tells your code who is really signed in.
🔖 Saved views#
Users can name the current state of a list (search, sort, filters, advanced search, visible columns, grouping, page size), come back to it from a Views menu, and share it with everyone who can see the resource (web and Flutter).
panel.SavedViews(nil) // in memory
panel.SavedViews(sqlStore.Views()) // in the database (pkg/sqlstore)
panel.SavedViewsShareable(
func(ctx *filament.Context) bool { return true }, // who may share
func(ctx *filament.Context) bool { return isAdmin(ctx.User()) }, // who may delete others' shared views
)
API: GET/POST /admin/api/resources/:slug/views, DELETE .../views/:id.
On the web, visible columns are chosen in the browser and are not part of a
saved view.
📥 Interactive Column-Mapping Import:#
- Upload CSV or TSV files via web modal (
/admin/{resource}/import) or REST API. - Smart Auto-Mapping: Automatically normalizes file headers (e.g.,
Customer Name$\rightarrow$customer_name$\rightarrow$name) to match model fields. - Explicit Mapping: Override column definitions with custom mapping fields.
- Batch Processing & Error Resilience: Processes rows sequentially with
OnCreate, collecting failure logs without terminating the batch. - Real-Time Notification: Dispatches toast and drawer notifications with success counts and warning reports via
notifications.Send(...).