增加对上传图片文件名称的校验
This commit is contained in:
@ -36,6 +36,13 @@ def add_project(info: ProjectInfoIn, session: Session, user_id: int):
|
||||
return project_info.id
|
||||
|
||||
|
||||
def check_image_name(project_id: int, files: List[UploadFile], session: Session):
|
||||
for file in files:
|
||||
if not pimc.check_img_name(project_id, file.filename, session):
|
||||
return False, file.filename
|
||||
return True, None
|
||||
|
||||
|
||||
def upload_project_image(project_info: ProjectInfoOut, files: List[UploadFile], session: Session):
|
||||
"""
|
||||
上传项目的图片
|
||||
@ -48,6 +55,7 @@ def upload_project_image(project_info: ProjectInfoOut, files: List[UploadFile],
|
||||
for file in files:
|
||||
image = ProjectImage()
|
||||
image.project_id = project_info.id
|
||||
image.file_name = file.filename
|
||||
# 保存原图
|
||||
path = os.save_images(images_url, project_info.project_no, file=file)
|
||||
image.image_url = path
|
||||
|
Reference in New Issue
Block a user