mintlee commited on
Commit
b14389a
·
1 Parent(s): dee7654
Files changed (1) hide show
  1. db/mongodb.py +4 -3
db/mongodb.py CHANGED
@@ -4,7 +4,7 @@ from bson import ObjectId
4
  import os
5
  from io import BytesIO
6
  import magic
7
- import time
8
 
9
  def connect_mongodb(db_name, collection_name):
10
  client = MongoClient("mongodb+srv://admin:[email protected]/?retryWrites=true&w=majority&appName=Cluster0")
@@ -31,8 +31,9 @@ def save_file_to_mongodb(uploaded_file, db_name="pptx", collection_name="root_fi
31
 
32
  # Sau khi dọn dẹp (nếu cần), tiến hành lưu
33
  file_id = fs.put(file_bytes, filename=file_name)
34
- now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
35
- print(f"{now:} File '{file_name}' đã được lưu vào '{collection_name}' với ID: {file_id} \n")
 
36
  return file_id, file_name
37
 
38
  except Exception as e:
 
4
  import os
5
  from io import BytesIO
6
  import magic
7
+ from datetime import datetime, timedelta
8
 
9
  def connect_mongodb(db_name, collection_name):
10
  client = MongoClient("mongodb+srv://admin:[email protected]/?retryWrites=true&w=majority&appName=Cluster0")
 
31
 
32
  # Sau khi dọn dẹp (nếu cần), tiến hành lưu
33
  file_id = fs.put(file_bytes, filename=file_name)
34
+ now = datetime.now() + timedelta(hours=5)
35
+ formatted_now = now.strftime("%Y-%m-%d %H:%M:%S")
36
+ print(f"{formatted_now} File '{file_name}' đã được lưu vào '{collection_name}' với ID: {file_id} \n")
37
  return file_id, file_name
38
 
39
  except Exception as e: