Skip to main content
PocketBase provides a unified filesystem abstraction for managing files both locally and on S3-compatible storage.

Creating filesystem instances

NewFilesystem()

Create a filesystem instance based on app settings:
Always call Close() on the filesystem when you’re done to release resources.

NewBackupsFilesystem()

Create a filesystem for managing backups:

Local filesystem

Create a local filesystem instance directly:

S3 filesystem

Create an S3-compatible filesystem:

S3-compatible services

The S3 filesystem works with any S3-compatible service:

File operations

Checking file existence

Getting file attributes

Reading files

Uploading files

Upload from bytes

Upload from multipart form

Deleting files

Delete a single file

Delete multiple files

Copying files

Listing files

File struct

The File struct represents a file to be uploaded:

Creating File instances

From multipart form

From bytes

From existing file

Working with record files

Uploading files to records

Accessing record files

Deleting record files

Files are automatically deleted when you remove them from a record:

File URLs

Generate URLs for accessing record files:

Image transformations

PocketBase automatically generates thumbnails for images:
Supported thumbnail formats:
  • 100x100 - Exact size with crop
  • 100x100f - Fit within bounds
  • 100x0 - Width only, auto height
  • 0x100 - Height only, auto width

File tokens

Generate temporary tokens for protected files:

Context management

Set a custom context for filesystem operations:

Best practices

Always close filesystems

Validate file types

Handle large files

Use transactions for file operations

Error handling

Check for not found errors