diff options
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; | ||