summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/FileServerService.ts
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2023-03-04 19:23:11 +0900
committerGitHub <noreply@github.com>2023-03-04 19:23:11 +0900
commitc36e7d1a070b684e08a5d967e99db5e03deb9534 (patch)
tree6626ae268789ba76f3073644ed84bc79f7eb506c /packages/backend/src/server/FileServerService.ts
parentFix: If mail delivery is disabled on the server, make the settings page indic... (diff)
downloadsharkey-c36e7d1a070b684e08a5d967e99db5e03deb9534.tar.gz
sharkey-c36e7d1a070b684e08a5d967e99db5e03deb9534.tar.bz2
sharkey-c36e7d1a070b684e08a5d967e99db5e03deb9534.zip
enhance(server): メディアプロキシでico,bmpを読めるように (#10186)
* enhance(server): downloadUrlでContent-Dispositionからファイル名を取得 Resolve #10036 Resolve #4750 * untitled * オブジェクトストレージのContent-Dispositionのファイル名の拡張子をContent-Typeに添ったものにする * :v: * tiff * fix filename * add test * /files/でもContent-Disposition * enhance(server): メディアプロキシでico,bmpを読めるように Fix #10120 * comment * fix test --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/backend/src/server/FileServerService.ts')
-rw-r--r--packages/backend/src/server/FileServerService.ts15
1 files changed, 8 insertions, 7 deletions
diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts
index 8eeb76f7c7..835657b625 100644
--- a/packages/backend/src/server/FileServerService.ts
+++ b/packages/backend/src/server/FileServerService.ts
@@ -22,6 +22,7 @@ import { bindThis } from '@/decorators.js';
import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify';
import { isMimeImage } from '@/misc/is-mime-image.js';
import sharp from 'sharp';
+import { sharpBmp } from 'sharp-read-bmp';
import { correctFilename } from '@/misc/correct-filename.js';
const _filename = fileURLToPath(import.meta.url);
@@ -132,7 +133,7 @@ export class FileServerService {
let image: IImageStreamable | null = null;
if (file.fileRole === 'thumbnail') {
- if (isMimeImage(file.mime, 'sharp-convertible-image')) {
+ if (isMimeImage(file.mime, 'sharp-convertible-image-with-bmp')) {
reply.header('Cache-Control', 'max-age=31536000, immutable');
const url = new URL(`${this.config.mediaProxy}/static.webp`);
@@ -257,8 +258,8 @@ export class FileServerService {
}
try {
- const isConvertibleImage = isMimeImage(file.mime, 'sharp-convertible-image');
- const isAnimationConvertibleImage = isMimeImage(file.mime, 'sharp-animation-convertible-image');
+ const isConvertibleImage = isMimeImage(file.mime, 'sharp-convertible-image-with-bmp');
+ const isAnimationConvertibleImage = isMimeImage(file.mime, 'sharp-animation-convertible-image-with-bmp');
if (
'emoji' in request.query ||
@@ -282,7 +283,7 @@ export class FileServerService {
type: file.mime,
};
} else {
- const data = sharp(file.path, { animated: !('static' in request.query) })
+ const data = (await sharpBmp(file.path, file.mime, { animated: !('static' in request.query) }))
.resize({
height: 'emoji' in request.query ? 128 : 320,
withoutEnlargement: true,
@@ -296,11 +297,11 @@ export class FileServerService {
};
}
} else if ('static' in request.query) {
- image = this.imageProcessingService.convertToWebpStream(file.path, 498, 280);
+ image = this.imageProcessingService.convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 498, 280);
} else if ('preview' in request.query) {
- image = this.imageProcessingService.convertToWebpStream(file.path, 200, 200);
+ image = this.imageProcessingService.convertSharpToWebpStream(await sharpBmp(file.path, file.mime), 200, 200);
} else if ('badge' in request.query) {
- const mask = sharp(file.path)
+ const mask = (await sharpBmp(file.path, file.mime))
.resize(96, 96, {
fit: 'inside',
withoutEnlargement: false,