From 773f67e254d85def150b1d6ab648e85966482d3c Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih Date: Sat, 6 Jan 2024 18:30:59 +0900 Subject: [PATCH] fix --- packages/backend/src/server/FileServerService.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index 346b2b6e68..6d42bf49f8 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -176,6 +176,7 @@ export class FileServerService { if (end > file.file.size) { end = file.file.size - 1; } + const chunksize = end - start + 1; image = { data: fs.createReadStream(file.path, { @@ -186,16 +187,16 @@ export class FileServerService { type: file.mime, }; - const chunksize = end - start + 1; reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`); reply.header('Accept-Ranges', 'bytes'); reply.header('Content-Length', chunksize); + } else { + image = { + data: fs.createReadStream(file.path), + ext: file.ext, + type: file.mime, + }; } - image = { - data: fs.createReadStream(file.path), - ext: file.ext, - type: file.mime, - }; } if ('pipe' in image.data && typeof image.data.pipe === 'function') {