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.
()
| 713 | // NB! Make sure to call Close() on the returned result |
| 714 | // after you are done working with it. |
| 715 | func (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. |