Jul 2nd - Optimized code 3
This commit is contained in:
@@ -86,22 +86,6 @@ def save_attachment(file, ticket_id=None, comment_id=None, uploader_id=None):
|
||||
)
|
||||
db.session.add(att)
|
||||
return att
|
||||
filename = secure_filename(file.filename)
|
||||
ext = filename.rsplit('.', 1)[1].lower() if '.' in filename else ''
|
||||
stored_name = f"{uuid.uuid4().hex}.{ext}"
|
||||
upload_dir = current_app.config['UPLOAD_FOLDER']
|
||||
file.save(os.path.join(upload_dir, stored_name))
|
||||
att = Attachment(
|
||||
ticket_id = ticket_id,
|
||||
comment_id = comment_id,
|
||||
filename = filename,
|
||||
stored_name= stored_name,
|
||||
file_size = os.path.getsize(os.path.join(upload_dir, stored_name)),
|
||||
mime_type = file.content_type,
|
||||
uploaded_by= uploader_id,
|
||||
)
|
||||
db.session.add(att)
|
||||
return att
|
||||
|
||||
|
||||
# ─── Dashboard ────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user