I now create a web app and I want to ask about how to upload PDFs from my laptop/local to Document AI - Summarizer Processor?
with open(file_path, "rb") as image: image_content = image.read()
uploaded_file = st.file_uploader('Choose your .pdf file', type="pdf")
process_document_sample(project_id="XXXX",location="us",processor_id="XXX", file_path=uploaded_file,mime_type="application/pdf" )
https://i.imgur.com/fqf30Xn.png
I want upload PDF from local/my laptop use Streamlit (uploaded_file) and can read my PDF with with open(file_path, "rb") as image function.
I expect I have idea - I want upload PDF from local to Document AI Python SDK use Streamlit (web app library) and can read PDF.
The Document AI API for online processing requests requires the input file to be encoded in
base64as a string, which the default Python File I/O does when exporting the bytes read.For Streamlit, you'll need to get the bytes of the uploaded file and input that value directly in the API request, rather than passing it to
In the Streamlit documentation, it looks like you are able to get the bytes data from an uploaded file. I'm not familiar with this framework, but you should be able to do something like this, using the code sample from Send a processing request.