dinhquangson commited on
Commit
4fac9ec
1 Parent(s): cae8ab9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -36,14 +36,17 @@ def get_pdf_pages(pdf_docs):
36
 
37
  """
38
  pages = []
39
- for pdf in pdf_docs:
40
- pdf_path=os.path.join("tempDir",pdf.name)
41
- with open(pdf_path, "wb") as f:
42
- f.write(pdf.getbuffer())
 
 
 
43
 
44
- pdf_loader = UnstructuredPDFLoader(pdf_path)
45
- pdf_pages = pdf_loader.load_and_split()
46
- pages=paegs+pdf_pages
47
  return pages
48
 
49
 
 
36
 
37
  """
38
  pages = []
39
+ import tempfile
40
+
41
+ with tempfile.TemporaryDirectory() as tmpdirname:
42
+ for pdf in pdf_docs:
43
+ pdf_path=os.path.join(tmpdirname,pdf.name)
44
+ with open(pdf_path, "wb") as f:
45
+ f.write(pdf.getbuffer())
46
 
47
+ pdf_loader = UnstructuredPDFLoader(pdf_path)
48
+ pdf_pages = pdf_loader.load_and_split()
49
+ pages=paegs+pdf_pages
50
  return pages
51
 
52