mirror of
https://github.com/veops/cmdb.git
synced 2025-08-08 22:04:04 +08:00
前后端全面升级
This commit is contained in:
16
cmdb-api/api/lib/common_setting/upload_file.py
Normal file
16
cmdb-api/api/lib/common_setting/upload_file.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import uuid
|
||||
|
||||
from api.lib.common_setting.utils import get_cur_time_str
|
||||
|
||||
|
||||
def allowed_file(filename, allowed_extensions):
|
||||
return '.' in filename and \
|
||||
filename.rsplit('.', 1)[1].lower() in allowed_extensions
|
||||
|
||||
|
||||
def generate_new_file_name(name):
|
||||
ext = name.split('.')[-1]
|
||||
prev_name = ''.join(name.split(f".{ext}")[:-1])
|
||||
uid = str(uuid.uuid4())
|
||||
cur_str = get_cur_time_str('_')
|
||||
return f"{prev_name}_{cur_str}_{uid}.{ext}"
|
Reference in New Issue
Block a user