File size: 405 Bytes
7e1235e
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import os
from fastapi import UploadFile
from app.vector_store import store_pdf

UPLOAD_DIR = "data/uploaded_pdfs"


def process_pdf(file: UploadFile):
    os.makedirs(UPLOAD_DIR, exist_ok=True)
    filepath = os.path.join(UPLOAD_DIR, file.filename)
    with open(filepath, "wb") as f:
        f.write(file.file.read())
    store_pdf(filepath)
    return {"status": "uploaded", "filename": file.filename}