From 4a9bf1fdc335d6d576cd66d5bec1877fe114bde4 Mon Sep 17 00:00:00 2001 From: ktianc Date: Thu, 16 Nov 2023 13:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kinit-api/utils/cache.py | 4 ++-- kinit-api/utils/file/file_base.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/kinit-api/utils/cache.py b/kinit-api/utils/cache.py index 8fba19d..b75b518 100644 --- a/kinit-api/utils/cache.py +++ b/kinit-api/utils/cache.py @@ -73,8 +73,8 @@ class Cache: async def get_tab_name(self, tab_name: str, retry: int = 3): """ 获取系统配置 - :params tab_name: 配置表标签名称 - :params retry_num: 重试次数 + :param tab_name: 配置表标签名称 + :param retry_num: 重试次数 """ result = await self.rd.get(tab_name) if not result and retry > 0: diff --git a/kinit-api/utils/file/file_base.py b/kinit-api/utils/file/file_base.py index e3d32f6..264dc84 100644 --- a/kinit-api/utils/file/file_base.py +++ b/kinit-api/utils/file/file_base.py @@ -18,7 +18,8 @@ class FileBase: IMAGE_ACCEPT = ["image/png", "image/jpeg", "image/gif", "image/x-icon"] VIDEO_ACCEPT = ["video/mp4", "video/mpeg"] - ALL_ACCEPT = [*IMAGE_ACCEPT, *VIDEO_ACCEPT] + AUDIO_ACCEPT = ["audio/wav", "audio/mp3", "audio/m4a", "audio/wma", "audio/ogg", "audio/mpeg", "audio/x-wav"] + ALL_ACCEPT = [*IMAGE_ACCEPT, *VIDEO_ACCEPT, *AUDIO_ACCEPT] @classmethod def generate_path(cls, path: str, filename): @@ -29,9 +30,9 @@ class FileBase: path = path[1:] if path[-1] == "/": path = path[:-1] - full_date = int(datetime.datetime.now().timestamp()) + today = str(int((datetime.datetime.now().replace(hour=0, minute=0, second=0)).timestamp())) _filename = str(int(datetime.datetime.now().timestamp())) + str(uuid.uuid4())[:8] - return f"{path}/{full_date}/{_filename}{os.path.splitext(filename)[-1]}" + return f"{path}/{today}/{_filename}{os.path.splitext(filename)[-1]}" @classmethod async def validate_file(cls, file: UploadFile, max_size: int = None, mime_types: list = None) -> bool: