From 07e2d1ead04f4650ba03759ebd8c30457e7ac302 Mon Sep 17 00:00:00 2001 From: an-lee Date: Thu, 11 Jan 2024 10:45:26 +0800 Subject: [PATCH] add size limit for audio/video --- enjoy/src/i18n/en.json | 2 ++ enjoy/src/i18n/zh-CN.json | 2 ++ enjoy/src/main/db/models/audio.ts | 7 +++++++ enjoy/src/main/db/models/video.ts | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/enjoy/src/i18n/en.json b/enjoy/src/i18n/en.json index 17441c2b..bb9b9657 100644 --- a/enjoy/src/i18n/en.json +++ b/enjoy/src/i18n/en.json @@ -21,6 +21,7 @@ "added": "Successfully added audio", "removed": "Successfully removed audio", "notFound": "Video not found", + "fileTooLarge": "File too large {{ file }}", "failedToAdd": "Failed to add audio, {{ error }}", "fileNotFound": "File not found {{file}}", "fileNotSupported": "File not supported {{file}}", @@ -45,6 +46,7 @@ "added": "Successfully added video", "removed": "Successfully removed video", "notFound": "Video not found", + "fileTooLarge": "File too large {{ file }}", "failedToAdd": "Failed to add video, {{ error }}", "fileNotFound": "File not found {{file}}", "fileNotSupported": "File not supported {{file}}", diff --git a/enjoy/src/i18n/zh-CN.json b/enjoy/src/i18n/zh-CN.json index ada25107..68c11f38 100644 --- a/enjoy/src/i18n/zh-CN.json +++ b/enjoy/src/i18n/zh-CN.json @@ -21,6 +21,7 @@ "added": "成功添加音频", "removed": "成功删除音频", "notFound": "未找到音频", + "fileTooLarge": "文件太大了 {{ file }}", "failedToAdd": "添加音频失败, {{error}}", "fileNotFound": "无法访问文件 {{file}}", "fileNotSupported": "文件不支持 {{file}}", @@ -45,6 +46,7 @@ "added": "成功添加视频", "removed": "成功删除视频", "notFound": "未找到视频", + "fileTooLarge": "文件太大了 {{ file }}", "failedToAdd": "添加视频失败, {{error}}", "fileNotFound": "无法访问文件 {{file}}", "fileNotSupported": "文件不支持 {{file}}", diff --git a/enjoy/src/main/db/models/audio.ts b/enjoy/src/main/db/models/audio.ts index 95ebc4b1..07973f0d 100644 --- a/enjoy/src/main/db/models/audio.ts +++ b/enjoy/src/main/db/models/audio.ts @@ -29,6 +29,8 @@ import webApi from "@main/web-api"; import { startCase } from "lodash"; import { v5 as uuidv5 } from "uuid"; +const SIZE_LIMIT = 1024 * 1024 * 50; // 50MB + const logger = log.scope("db/models/audio"); @Table({ modelName: "Audio", @@ -240,6 +242,11 @@ export class Audio extends Model