diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-02-10 22:36:13 +0100 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-02-10 22:36:13 +0100 |
commit | 62b0b360fa8a1a2d1fd6d89d4d227a0ef559cb8a (patch) | |
tree | 5db624a9ac4ce011c18941cbdd13da6e76492c58 /src/Env.php | |
parent | 2eb5a432d2229788ce2fdb09f36c6f4bebdea813 (diff) | |
download | micropoly-62b0b360fa8a1a2d1fd6d89d4d227a0ef559cb8a.tar.gz micropoly-62b0b360fa8a1a2d1fd6d89d4d227a0ef559cb8a.tar.bz2 micropoly-62b0b360fa8a1a2d1fd6d89d4d227a0ef559cb8a.zip |
Implement simple attachment support
It is now possible to upload and view attachments!
Attachments are saved by their content hash, therefore they are
automatically deduplicated and we can later easily add integrity checks.
Still missing:
- Deleting attachments
- Multiple file inputs (idea: when the user fills in a file input, create a
new empty file input beneath with js)
- (nice to have) Thumbnails
Diffstat (limited to 'src/Env.php')
-rw-r--r-- | src/Env.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Env.php b/src/Env.php index 34b9f1f..38d9279 100644 --- a/src/Env.php +++ b/src/Env.php @@ -2,6 +2,7 @@ namespace Micropoly; +use RuntimeException; use SQLite3; use Twig\Environment; use Twig\Loader\FilesystemLoader; @@ -77,4 +78,12 @@ class Env return $db; }); } + + public function attachmentsPath(): string + { + $attachments = $this->config['attachments']; + if (!is_dir($attachments) || !is_writable($attachments)) + throw new RuntimeException("Attachment directory '$attachments' is not a writable directory."); + return $attachments; + } } |