summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2020-01-04 07:20:41 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-01-04 07:20:41 +0900
commite37840d870eec41599cde71baee70e3688e21f32 (patch)
treed32ba90ff25ca7491ea74beb871fdc36bc8e4101 /src/server
parent2020 (diff)
downloadsharkey-e37840d870eec41599cde71baee70e3688e21f32.tar.gz
sharkey-e37840d870eec41599cde71baee70e3688e21f32.tar.bz2
sharkey-e37840d870eec41599cde71baee70e3688e21f32.zip
ドライブ関連の修正 (#5673)
* :v: * Update add-file.ts * fix
Diffstat (limited to 'src/server')
-rw-r--r--src/server/file/send-drive-file.ts25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/server/file/send-drive-file.ts b/src/server/file/send-drive-file.ts
index 1a43e5dc42..2283435794 100644
--- a/src/server/file/send-drive-file.ts
+++ b/src/server/file/send-drive-file.ts
@@ -9,7 +9,7 @@ import { DriveFiles } from '../../models';
import { InternalStorage } from '../../services/drive/internal-storage';
import { downloadUrl } from '../../misc/donwload-url';
import { detectMine } from '../../misc/detect-mine';
-import { convertToJpeg, convertToPng, convertToGif, convertToApng } from '../../services/drive/image-processor';
+import { convertToJpeg, convertToPng } from '../../services/drive/image-processor';
import { GenerateVideoThumbnail } from '../../services/drive/generate-video-thumbnail';
const assets = `${__dirname}/../../server/file/assets/`;
@@ -60,10 +60,6 @@ export default async function(ctx: Koa.Context) {
return await convertToJpeg(path, 498, 280);
} else if (['image/png'].includes(type)) {
return await convertToPng(path, 498, 280);
- } else if (['image/gif'].includes(type)) {
- return await convertToGif(path);
- } else if (['image/apng', 'image/vnd.mozilla.apng'].includes(type)) {
- return await convertToApng(path);
} else if (type.startsWith('video/')) {
return await GenerateVideoThumbnail(path);
}
@@ -101,22 +97,23 @@ export default async function(ctx: Koa.Context) {
return;
}
- if (isThumbnail) {
- ctx.body = InternalStorage.read(key);
- ctx.set('Content-Type', 'image/jpeg');
- ctx.set('Cache-Control', 'max-age=31536000, immutable');
- ctx.set('Content-Disposition', contentDisposition('inline', `${rename(file.name, { suffix: '-thumb', extname: '.jpeg' })}`));
- } else if (isWebpublic) {
+ if (isThumbnail || isWebpublic) {
+ const [mime, ext] = await detectMine(InternalStorage.resolvePath(key));
+ const filename = rename(file.name, {
+ suffix: isThumbnail ? '-thumb' : '-web',
+ extname: ext ? `.${ext}` : undefined
+ }).toString();
+
ctx.body = InternalStorage.read(key);
- ctx.set('Content-Type', file.type === 'image/apng' ? 'image/png' : file.type);
+ ctx.set('Content-Type', mime);
ctx.set('Cache-Control', 'max-age=31536000, immutable');
- ctx.set('Content-Disposition', contentDisposition('inline', `${rename(file.name, { suffix: '-web' })}`));
+ ctx.set('Content-Disposition', contentDisposition('inline', filename));
} else {
const readable = InternalStorage.read(file.accessKey!);
readable.on('error', commonReadableHandlerGenerator(ctx));
ctx.body = readable;
ctx.set('Content-Type', file.type);
ctx.set('Cache-Control', 'max-age=31536000, immutable');
- ctx.set('Content-Disposition', contentDisposition('inline', `${file.name}`));
+ ctx.set('Content-Disposition', contentDisposition('inline', file.name));
}
}