diff options
| author | Maksymilian Jopek <maks@jopek.eu> | 2023-04-13 23:19:23 +0200 |
|---|---|---|
| committer | Maksymilian Jopek <maks@jopek.eu> | 2023-04-13 23:19:23 +0200 |
| commit | 1871b834a715be2e8c4e25938cf3db3866a80ec6 (patch) | |
| tree | cb5eba8e41a1aa19d9d511567f901d73b89e0981 /backend/main.js | |
| parent | 4582aee9c51800f7b236fc9d731829c16254429f (diff) | |
| download | aparatus-master.tar.gz aparatus-master.tar.zst aparatus-master.zip | |
Fix bug when without upload folder
Diffstat (limited to 'backend/main.js')
| -rw-r--r-- | backend/main.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/backend/main.js b/backend/main.js index ae330b1..2ec749f 100644 --- a/backend/main.js +++ b/backend/main.js @@ -1,6 +1,7 @@ const express = require("express"); const formidable = require('formidable'); const fs = require("fs").promises +const fss = require("fs") const app = express(); app.use(express.static('static')) @@ -40,7 +41,10 @@ app.post('/rename-file', async (req, res) => { app.get('/files', async (_, res) => { res.json(await fs.readdir(__dirname + '/static/upload')) }); + +if (!fss.existsSync(uploadDir)){ + fss.mkdirSync(uploadDir); +} app.listen(PORT, () => { console.log("Server listening on port " + PORT); }) - |
