Remove "upload" endpoint from assets API

I accidentally reintroduced this when splitting up the commits, I think
This commit is contained in:
valadaptive 2023-12-05 15:02:30 -05:00
parent 6ea9269592
commit 4faa20bb1f
1 changed files with 0 additions and 27 deletions

View File

@ -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 };