aboutsummaryrefslogtreecommitdiffstats
path: root/src/internal-server/app/Controllers/Http/ImageController.js
blob: 9b11783c76a322aee038785031508b62130e8801 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const Env = use('Env');

const path = require('path');
const fs = require('fs-extra');

class ImageController {
  async icon({ params, response }) {
    const { id } = params;

    const iconPath = path.join(Env.get('USER_PATH'), 'icons', id);
    if (!fs.existsSync(iconPath)) {
      return response.status(404).send({
        status: "Icon doesn't exist",
      });
    }

    return response.download(iconPath);
  }
}

module.exports = ImageController;