3 * @copyright Copyright (C) 2010-2021, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Model\Storage;
24 use Friendica\Core\Config\IConfig;
25 use Friendica\Core\L10n;
28 * Filesystem based storage backend configuration
30 class FilesystemConfig implements IStorageConfiguration
32 // Default base folder
33 const DEFAULT_BASE_FOLDER = 'storage';
45 * Returns the current storage path
49 public function getStoragePath(): string
51 return $this->storagePath;
55 * Filesystem constructor.
57 * @param IConfig $config
60 public function __construct(IConfig $config, L10n $l10n)
62 $this->config = $config;
65 $path = $this->config->get('storage', 'filesystem_path', self::DEFAULT_BASE_FOLDER);
66 $this->storagePath = rtrim($path, '/');
72 public function getOptions(): array
77 $this->l10n->t('Storage base path'),
79 $this->l10n->t('Folder where uploaded files are saved. For maximum security, This should be a path outside web server folder tree')
87 public function saveOptions(array $data): array
89 $storagePath = $data['storagepath'] ?? '';
90 if ($storagePath === '' || !is_dir($storagePath)) {
92 'storagepath' => $this->l10n->t('Enter a valid existing folder')
95 $this->config->set('storage', 'filesystem_path', $storagePath);
96 $this->storagePath = $storagePath;