Update the range end to load 1MB at a time instead of requesting the whole file

This commit is contained in:
mbaharip
2024-05-06 02:02:46 +07:00
parent 3c0a1fdc8e
commit cd20ad7222
+3 -1
View File
@@ -59,7 +59,9 @@ export async function GET(
const rangeSize = ranges.match(rangeRegex);
if (rangeSize) {
rangeStart = parseInt(rangeSize[1], 10);
rangeEnd = rangeSize ? parseInt(rangeSize[2], 10) : fileSize - 1;
const chunkSize = 1024 * 1024; // Load 1MB at a time
rangeEnd = Math.min(rangeStart + chunkSize, fileSize - 1);
}
const contentRange = `bytes=${rangeStart}-${Math.min(