Fix: compress cover uploads and raise API payload limit
This commit is contained in:
@@ -27,11 +27,12 @@ function sendJson(response, statusCode, payload) {
|
||||
async function readJsonBody(request) {
|
||||
const chunks = [];
|
||||
let size = 0;
|
||||
const maxPayloadSizeBytes = 8 * 1024 * 1024;
|
||||
|
||||
for await (const chunk of request) {
|
||||
size += chunk.length;
|
||||
if (size > 1024 * 1024) {
|
||||
throw new Error("Payload too large");
|
||||
if (size > maxPayloadSizeBytes) {
|
||||
throw new Error("Payload too large (max 8MB)");
|
||||
}
|
||||
chunks.push(chunk);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user