Skip to content

Commit

Permalink
Fix files
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Apr 14, 2024
1 parent 8c5d9a6 commit 57ceb4a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/backend/src/server/FileServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ export class FileServerService {
}

reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(image.type) ? image.type : 'application/octet-stream');
reply.header('Content-Length', file.file.size);
reply.header('Cache-Control', 'max-age=31536000, immutable');
reply.header('Content-Disposition',
contentDisposition(
'inline',
Expand Down Expand Up @@ -256,6 +258,7 @@ export class FileServerService {
return fs.createReadStream(file.path);
} else {
reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(file.file.type) ? file.file.type : 'application/octet-stream');
reply.header('Content-Length', file.file.size);
reply.header('Cache-Control', 'max-age=31536000, immutable');
reply.header('Content-Disposition', contentDisposition('inline', file.filename));

Expand Down Expand Up @@ -530,9 +533,7 @@ export class FileServerService {
if (!file.storedInternal) {
if (!(file.isLink && file.uri)) return '204';
const result = await this.downloadAndDetectTypeFromUrl(file.uri);
if (!file.size) {
file.size = (await fs.promises.stat(result.path)).size;
}
file.size = (await fs.promises.stat(result.path)).size; // DB file.sizeは正確とは限らないので
return {
...result,
url: file.uri,
Expand Down

0 comments on commit 57ceb4a

Please sign in to comment.