summaryrefslogtreecommitdiff
path: root/src/server/file
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2020-01-12 16:40:58 +0900
committerGitHub <noreply@github.com>2020-01-12 16:40:58 +0900
commit9703ba53405b2f355c6e0317f714d82ff3d4dee3 (patch)
tree4cd80df78b5c78bb60d47179836d393ee8d805d4 /src/server/file
parentRefactor (diff)
downloadsharkey-9703ba53405b2f355c6e0317f714d82ff3d4dee3.tar.gz
sharkey-9703ba53405b2f355c6e0317f714d82ff3d4dee3.tar.bz2
sharkey-9703ba53405b2f355c6e0317f714d82ff3d4dee3.zip
ファイルと画像認識処理の改善 (#5690)
* dimensions制限とリファクタ * comment * 不要な変更削除 * use fromFile など * Add probe-image-size.d.ts * えーCRLFで作るなよ… * Update src/@types/probe-image-size.d.ts Co-Authored-By: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * fix d.ts * Update src/@types/probe-image-size.d.ts Co-Authored-By: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * Update src/@types/probe-image-size.d.ts Co-Authored-By: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * fix Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Diffstat (limited to 'src/server/file')
-rw-r--r--src/server/file/send-drive-file.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/server/file/send-drive-file.ts b/src/server/file/send-drive-file.ts
index 2283435794..0b14378589 100644
--- a/src/server/file/send-drive-file.ts
+++ b/src/server/file/send-drive-file.ts
@@ -8,7 +8,7 @@ import { contentDisposition } from '../../misc/content-disposition';
import { DriveFiles } from '../../models';
import { InternalStorage } from '../../services/drive/internal-storage';
import { downloadUrl } from '../../misc/donwload-url';
-import { detectMine } from '../../misc/detect-mine';
+import { detectType } from '../../misc/get-file-info';
import { convertToJpeg, convertToPng } from '../../services/drive/image-processor';
import { GenerateVideoThumbnail } from '../../services/drive/generate-video-thumbnail';
@@ -52,15 +52,15 @@ export default async function(ctx: Koa.Context) {
try {
await downloadUrl(file.uri, path);
- const [type, ext] = await detectMine(path);
+ const { mime, ext } = await detectType(path);
const convertFile = async () => {
if (isThumbnail) {
- if (['image/jpeg', 'image/webp'].includes(type)) {
+ if (['image/jpeg', 'image/webp'].includes(mime)) {
return await convertToJpeg(path, 498, 280);
- } else if (['image/png'].includes(type)) {
+ } else if (['image/png'].includes(mime)) {
return await convertToPng(path, 498, 280);
- } else if (type.startsWith('video/')) {
+ } else if (mime.startsWith('video/')) {
return await GenerateVideoThumbnail(path);
}
}
@@ -68,7 +68,7 @@ export default async function(ctx: Koa.Context) {
return {
data: fs.readFileSync(path),
ext,
- type,
+ type: mime,
};
};