diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2022-05-14 21:46:47 -0500 |
---|---|---|
committer | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2022-05-15 15:13:19 -0500 |
commit | b153a938645a0c2193a20967325ca855ab671073 (patch) | |
tree | dd126334c16ea46136648147edde0e8125137947 /src/internal-server/app/Controllers/Http/ImageController.js | |
parent | Upgrade 'pnpm' to '7.1.0'; pull in latst version of 'recipes' [skip ci] (diff) | |
download | ferdium-app-b153a938645a0c2193a20967325ca855ab671073.tar.gz ferdium-app-b153a938645a0c2193a20967325ca855ab671073.tar.zst ferdium-app-b153a938645a0c2193a20967325ca855ab671073.zip |
Extracted ImageHelper and ImageController from ServiceController for reuse
Diffstat (limited to 'src/internal-server/app/Controllers/Http/ImageController.js')
-rw-r--r-- | src/internal-server/app/Controllers/Http/ImageController.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/internal-server/app/Controllers/Http/ImageController.js b/src/internal-server/app/Controllers/Http/ImageController.js new file mode 100644 index 000000000..9b11783c7 --- /dev/null +++ b/src/internal-server/app/Controllers/Http/ImageController.js | |||
@@ -0,0 +1,21 @@ | |||
1 | const Env = use('Env'); | ||
2 | |||
3 | const path = require('path'); | ||
4 | const fs = require('fs-extra'); | ||
5 | |||
6 | class ImageController { | ||
7 | async icon({ params, response }) { | ||
8 | const { id } = params; | ||
9 | |||
10 | const iconPath = path.join(Env.get('USER_PATH'), 'icons', id); | ||
11 | if (!fs.existsSync(iconPath)) { | ||
12 | return response.status(404).send({ | ||
13 | status: "Icon doesn't exist", | ||
14 | }); | ||
15 | } | ||
16 | |||
17 | return response.download(iconPath); | ||
18 | } | ||
19 | } | ||
20 | |||
21 | module.exports = ImageController; | ||