Properly request only the first 1024 bytes when getting image type

This commit is contained in:
TheEssem 2021-01-04 11:10:57 -06:00
parent dd114e27b5
commit 2a3f84f628

View file

@ -93,7 +93,9 @@ exports.getType = async (image) => {
controller.abort(); controller.abort();
}, 25000); }, 25000);
try { try {
const imageRequest = await fetch(image, { signal: controller.signal, highWaterMark: 512 }); const imageRequest = await fetch(image, { signal: controller.signal, headers: {
"Range": "bytes=0-1023"
}});
clearTimeout(timeout); clearTimeout(timeout);
const imageBuffer = await imageRequest.buffer(); const imageBuffer = await imageRequest.buffer();
const imageType = await fileType.fromBuffer(imageBuffer); const imageType = await fileType.fromBuffer(imageBuffer);