From f3f02e80950b4699b207c16c785308d0cf911fe6 Mon Sep 17 00:00:00 2001 From: srgooglo Date: Thu, 5 May 2022 10:45:10 +0200 Subject: [PATCH] disable upload endpoints --- .../src/controllers/FilesController/index.js | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/server/src/controllers/FilesController/index.js b/packages/server/src/controllers/FilesController/index.js index 5b9f5c21..f40af947 100644 --- a/packages/server/src/controllers/FilesController/index.js +++ b/packages/server/src/controllers/FilesController/index.js @@ -11,24 +11,28 @@ export default class FilesController extends ComplexController { static refName = "FilesController" get = { - "/uploads/:id": (req, res) => { - const filePath = path.join(global.uploadPath, req.params?.id) + "/uploads/:id": { + enabled: false, + fn: (req, res) => { + const filePath = path.join(global.uploadPath, req.params?.id) - const readStream = fs.createReadStream(filePath) - const passTrough = new stream.PassThrough() + const readStream = fs.createReadStream(filePath) + const passTrough = new stream.PassThrough() - stream.pipeline(readStream, passTrough, (err) => { - if (err) { - return res.status(400) - } - }) + stream.pipeline(readStream, passTrough, (err) => { + if (err) { + return res.status(400) + } + }) - return passTrough.pipe(res) + return passTrough.pipe(res) + }, } } post = { "/upload": { + enabled: false, middlewares: ["withAuthentication", "fileUpload"], fn: async (req, res) => { const urls = []