mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Use a unique name for the temp PDF generated
This commit is contained in:
@@ -3,6 +3,7 @@ import base64
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
# External Packages
|
# External Packages
|
||||||
from langchain.document_loaders import PyMuPDFLoader
|
from langchain.document_loaders import PyMuPDFLoader
|
||||||
@@ -66,7 +67,8 @@ class PdfToEntries(TextToEntries):
|
|||||||
for pdf_file in pdf_files:
|
for pdf_file in pdf_files:
|
||||||
try:
|
try:
|
||||||
# Write the PDF file to a temporary file, as it is stored in byte format in the pdf_file object and the PDF Loader expects a file path
|
# Write the PDF file to a temporary file, as it is stored in byte format in the pdf_file object and the PDF Loader expects a file path
|
||||||
tmp_file = f"tmp_pdf_file.pdf"
|
timestamp_now = datetime.utcnow().timestamp()
|
||||||
|
tmp_file = f"tmp_pdf_file_{timestamp_now}.pdf"
|
||||||
with open(f"{tmp_file}", "wb") as f:
|
with open(f"{tmp_file}", "wb") as f:
|
||||||
bytes = pdf_files[pdf_file]
|
bytes = pdf_files[pdf_file]
|
||||||
f.write(bytes)
|
f.write(bytes)
|
||||||
|
|||||||
Reference in New Issue
Block a user