From 4faa20bb1f984421632785d76cd76176fcb55cbd Mon Sep 17 00:00:00 2001 From: valadaptive Date: Tue, 5 Dec 2023 15:02:30 -0500 Subject: [PATCH] Remove "upload" endpoint from assets API I accidentally reintroduced this when splitting up the commits, I think --- src/endpoints/assets.js | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/endpoints/assets.js b/src/endpoints/assets.js index 442e59fe3..cfaa55f2b 100644 --- a/src/endpoints/assets.js +++ b/src/endpoints/assets.js @@ -4,7 +4,6 @@ const express = require('express'); const sanitize = require('sanitize-filename'); const fetch = require('node-fetch').default; const { finished } = require('stream/promises'); -const writeFileSyncAtomic = require('write-file-atomic').sync; const { DIRECTORIES, UNSAFE_EXTENSIONS } = require('../constants'); const { jsonParser } = require('../express-common'); @@ -290,30 +289,4 @@ router.post('/character', jsonParser, async (request, response) => { } }); -router.post('/upload', jsonParser, async (request, response) => { - try { - if (!request.body.name) { - return response.status(400).send('No upload name specified'); - } - - if (!request.body.data) { - return response.status(400).send('No upload data specified'); - } - - const safeInput = sanitizeAssetFileName(request.body.name); - - if (!safeInput) { - return response.status(400).send('Invalid upload name'); - } - - const pathToUpload = path.join(DIRECTORIES.files, safeInput); - writeFileSyncAtomic(pathToUpload, request.body.data, 'base64'); - const url = path.normalize(pathToUpload.replace('public' + path.sep, '')); - return response.send({ path: url }); - } catch (error) { - console.log(error); - return response.sendStatus(500); - } -}); - module.exports = { router, sanitizeAssetFileName };