MCPcopy
hub / github.com/pocketbase/pocketbase / NewFilesystem

Method NewFilesystem

core/base.go:715–729  ·  view source on GitHub ↗

NewFilesystem creates a new local or S3 filesystem instance for managing regular app files (ex. record uploads) based on the current app settings. NB! Make sure to call Close() on the returned result after you are done working with it.

()

Source from the content-addressed store, hash-verified

713// NB! Make sure to call Close() on the returned result
714// after you are done working with it.
715func (app *BaseApp) NewFilesystem() (*filesystem.System, error) {
716 if app.settings != nil && app.settings.S3.Enabled {
717 return filesystem.NewS3(
718 app.settings.S3.Bucket,
719 app.settings.S3.Region,
720 app.settings.S3.Endpoint,
721 app.settings.S3.AccessKey,
722 app.settings.S3.Secret,
723 app.settings.S3.ForcePathStyle,
724 )
725 }
726
727 // fallback to local filesystem
728 return filesystem.NewLocal(filepath.Join(app.DataDir(), LocalStorageDirName))
729}
730
731// NewBackupsFilesystem creates a new local or S3 filesystem instance
732// for managing app backups based on the current app settings.

Callers 2

registerBaseHooksMethod · 0.95
TestBaseAppNewFilesystemFunction · 0.95

Calls 3

DataDirMethod · 0.95
NewS3Function · 0.92
NewLocalFunction · 0.92

Tested by 1

TestBaseAppNewFilesystemFunction · 0.76