summaryrefslogtreecommitdiff
path: root/src/server/proxy
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/proxy
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/proxy')
-rw-r--r--src/server/proxy/proxy-media.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/server/proxy/proxy-media.ts b/src/server/proxy/proxy-media.ts
index 232b7a09cd..6b90e99921 100644
--- a/src/server/proxy/proxy-media.ts
+++ b/src/server/proxy/proxy-media.ts
@@ -4,7 +4,7 @@ import { serverLogger } from '..';
import { IImage, convertToPng, convertToJpeg } from '../../services/drive/image-processor';
import { createTemp } from '../../misc/create-temp';
import { downloadUrl } from '../../misc/donwload-url';
-import { detectMine } from '../../misc/detect-mine';
+import { detectType } from '../../misc/get-file-info';
export async function proxyMedia(ctx: Koa.Context) {
const url = 'url' in ctx.query ? ctx.query.url : 'https://' + ctx.params.url;
@@ -15,21 +15,21 @@ export async function proxyMedia(ctx: Koa.Context) {
try {
await downloadUrl(url, path);
- const [type, ext] = await detectMine(path);
+ const { mime, ext } = await detectType(path);
- if (!type.startsWith('image/')) throw 403;
+ if (!mime.startsWith('image/')) throw 403;
let image: IImage;
- if ('static' in ctx.query && ['image/png', 'image/gif', 'image/apng', 'image/vnd.mozilla.apng'].includes(type)) {
+ if ('static' in ctx.query && ['image/png', 'image/gif', 'image/apng', 'image/vnd.mozilla.apng'].includes(mime)) {
image = await convertToPng(path, 498, 280);
- } else if ('preview' in ctx.query && ['image/jpeg', 'image/png', 'image/gif', 'image/apng', 'image/vnd.mozilla.apng'].includes(type)) {
+ } else if ('preview' in ctx.query && ['image/jpeg', 'image/png', 'image/gif', 'image/apng', 'image/vnd.mozilla.apng'].includes(mime)) {
image = await convertToJpeg(path, 200, 200);
} else {
image = {
data: fs.readFileSync(path),
ext,
- type,
+ type: mime,
};
}