This commit is contained in:
kakkokari-gtyih 2024-01-06 18:30:59 +09:00
parent 81b50498ee
commit 773f67e254

View file

@ -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,17 +187,17 @@ 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,
};
}
}
if ('pipe' in image.data && typeof image.data.pipe === 'function') {
// image.dataがstreamなら、stream終了後にcleanup