disable upload endpoints

This commit is contained in:
srgooglo 2022-05-05 10:45:10 +02:00
parent dddee4009b
commit f3f02e8095

View File

@ -11,24 +11,28 @@ export default class FilesController extends ComplexController {
static refName = "FilesController" static refName = "FilesController"
get = { get = {
"/uploads/:id": (req, res) => { "/uploads/:id": {
const filePath = path.join(global.uploadPath, req.params?.id) enabled: false,
fn: (req, res) => {
const filePath = path.join(global.uploadPath, req.params?.id)
const readStream = fs.createReadStream(filePath) const readStream = fs.createReadStream(filePath)
const passTrough = new stream.PassThrough() const passTrough = new stream.PassThrough()
stream.pipeline(readStream, passTrough, (err) => { stream.pipeline(readStream, passTrough, (err) => {
if (err) { if (err) {
return res.status(400) return res.status(400)
} }
}) })
return passTrough.pipe(res) return passTrough.pipe(res)
},
} }
} }
post = { post = {
"/upload": { "/upload": {
enabled: false,
middlewares: ["withAuthentication", "fileUpload"], middlewares: ["withAuthentication", "fileUpload"],
fn: async (req, res) => { fn: async (req, res) => {
const urls = [] const urls = []