mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-26 14:50:20 +01:00
send-drive-file svg as png (#8107)
This commit is contained in:
parent
74df9b57ec
commit
7627c43dee
1 changed files with 8 additions and 2 deletions
|
@ -11,7 +11,7 @@ import { DriveFiles } from '@/models/index';
|
||||||
import { InternalStorage } from '@/services/drive/internal-storage';
|
import { InternalStorage } from '@/services/drive/internal-storage';
|
||||||
import { downloadUrl } from '@/misc/download-url';
|
import { downloadUrl } from '@/misc/download-url';
|
||||||
import { detectType } from '@/misc/get-file-info';
|
import { detectType } from '@/misc/get-file-info';
|
||||||
import { convertToJpeg, convertToPngOrJpeg } from '@/services/drive/image-processor';
|
import { convertToJpeg, convertToPng, convertToPngOrJpeg } from '@/services/drive/image-processor';
|
||||||
import { GenerateVideoThumbnail } from '@/services/drive/generate-video-thumbnail';
|
import { GenerateVideoThumbnail } from '@/services/drive/generate-video-thumbnail';
|
||||||
import { StatusError } from '@/misc/fetch';
|
import { StatusError } from '@/misc/fetch';
|
||||||
import { FILE_TYPE_BROWSERSAFE } from '@/const';
|
import { FILE_TYPE_BROWSERSAFE } from '@/const';
|
||||||
|
@ -67,13 +67,19 @@ export default async function(ctx: Koa.Context) {
|
||||||
if (isThumbnail) {
|
if (isThumbnail) {
|
||||||
if (['image/jpeg', 'image/webp'].includes(mime)) {
|
if (['image/jpeg', 'image/webp'].includes(mime)) {
|
||||||
return await convertToJpeg(path, 498, 280);
|
return await convertToJpeg(path, 498, 280);
|
||||||
} else if (['image/png'].includes(mime)) {
|
} else if (['image/png', 'image/svg+xml'].includes(mime)) {
|
||||||
return await convertToPngOrJpeg(path, 498, 280);
|
return await convertToPngOrJpeg(path, 498, 280);
|
||||||
} else if (mime.startsWith('video/')) {
|
} else if (mime.startsWith('video/')) {
|
||||||
return await GenerateVideoThumbnail(path);
|
return await GenerateVideoThumbnail(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isWebpublic) {
|
||||||
|
if (['image/svg+xml'].includes(mime)) {
|
||||||
|
return await convertToPng(path, 2048, 2048);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: fs.readFileSync(path),
|
data: fs.readFileSync(path),
|
||||||
ext,
|
ext,
|
||||||
|
|
Loading…
Reference in a new issue