This commit is contained in:
kakkokari-gtyih 2024-01-06 18:30:59 +09:00
parent 81b50498ee
commit 773f67e254
1 changed files with 7 additions and 6 deletions

View File

@ -176,6 +176,7 @@ export class FileServerService {
if (end > file.file.size) { if (end > file.file.size) {
end = file.file.size - 1; end = file.file.size - 1;
} }
const chunksize = end - start + 1;
image = { image = {
data: fs.createReadStream(file.path, { data: fs.createReadStream(file.path, {
@ -186,16 +187,16 @@ export class FileServerService {
type: file.mime, type: file.mime,
}; };
const chunksize = end - start + 1;
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`); reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
reply.header('Accept-Ranges', 'bytes'); reply.header('Accept-Ranges', 'bytes');
reply.header('Content-Length', chunksize); 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') { if ('pipe' in image.data && typeof image.data.pipe === 'function') {