Spaces:
Sleeping
Sleeping
Update driveapi/drive.py
Browse files- 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 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
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]
|