diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-04-29 16:40:58 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-04-29 16:40:58 +0900 |
| commit | e8177ee3118beb18a7257de2b3a39ae4fadad4b1 (patch) | |
| tree | 96f9f7125a865ad875d43b37b483a806e3515927 /packages/backend/src/core/FileInfoService.ts | |
| parent | Update about-misskey.vue (diff) | |
| parent | feat(client): Renoteした人の一覧を表示するダイアログを追加... (diff) | |
| download | sharkey-e8177ee3118beb18a7257de2b3a39ae4fadad4b1.tar.gz sharkey-e8177ee3118beb18a7257de2b3a39ae4fadad4b1.tar.bz2 sharkey-e8177ee3118beb18a7257de2b3a39ae4fadad4b1.zip | |
Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop
Diffstat (limited to 'packages/backend/src/core/FileInfoService.ts')
| -rw-r--r-- | packages/backend/src/core/FileInfoService.ts | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/packages/backend/src/core/FileInfoService.ts b/packages/backend/src/core/FileInfoService.ts index e39b134b7e..b6cae5ea75 100644 --- a/packages/backend/src/core/FileInfoService.ts +++ b/packages/backend/src/core/FileInfoService.ts @@ -5,7 +5,7 @@ import * as stream from 'node:stream'; import * as util from 'node:util'; import { Injectable } from '@nestjs/common'; import { FSWatcher } from 'chokidar'; -import { fileTypeFromFile } from 'file-type'; +import * as fileType from 'file-type'; import FFmpeg from 'fluent-ffmpeg'; import isSvg from 'is-svg'; import probeImageSize from 'probe-image-size'; @@ -301,21 +301,34 @@ export class FileInfoService { return fs.promises.access(path).then(() => true, () => false); } + @bindThis + public fixMime(mime: string | fileType.MimeType): string { + // see https://github.com/misskey-dev/misskey/pull/10686 + if (mime === "audio/x-flac") { + return "audio/flac"; + } + if (mime === "audio/vnd.wave") { + return "audio/wav"; + } + + return mime; + } + /** * Detect MIME Type and extension */ @bindThis public async detectType(path: string): Promise<{ - mime: string; - ext: string | null; -}> { + mime: string; + ext: string | null; + }> { // Check 0 byte const fileSize = await this.getFileSize(path); if (fileSize === 0) { return TYPE_OCTET_STREAM; } - const type = await fileTypeFromFile(path); + const type = await fileType.fileTypeFromFile(path); if (type) { // XMLはSVGかもしれない @@ -324,7 +337,7 @@ export class FileInfoService { } return { - mime: type.mime, + mime: this.fixMime(type.mime), ext: type.ext, }; } |