Koshti10 commited on
Commit
de36b7a
·
verified ·
1 Parent(s): acd4a3d

Update driveapi/drive.py

Browse files
Files changed (1) hide show
  1. driveapi/drive.py +5 -4
driveapi/drive.py CHANGED
@@ -50,10 +50,11 @@ def download_file(file_id):
50
 
51
  # Function to process a PDF file
52
  def process_pdf(file_stream):
53
- print(f"File stream is of type: {type(file_stream)}")
54
- print(f"File stream is : {file_stream}")
55
- file_path = file_stream['name'] # Use 'path' for local testing and 'name' for Gradio
56
- pdf_reader = PyPDF2.PdfReader(file_path)
 
57
  text = ""
58
  for page_num in range(len(pdf_reader.pages)):
59
  page = pdf_reader.pages[page_num]
 
50
 
51
  # Function to process a PDF file
52
  def process_pdf(file_stream):
53
+ if isinstance(file_stream, dict): # Check if PDF was obtained using Drag and Drop or Drive link
54
+ file_path = file_stream['name'] # Use 'path' for local testing and 'name' for Gradio
55
+ pdf_reader = PyPDF2.PdfReader(file_path)
56
+ else:
57
+ pdf_reader = PyPDF2.PdfReader(file_stream)
58
  text = ""
59
  for page_num in range(len(pdf_reader.pages)):
60
  page = pdf_reader.pages[page_num]