Spaces:
Sleeping
Sleeping
Create utils.py
Browse files
utils.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
def save_pdf_to_directory(uploaded_file, directory):
|
| 5 |
+
if uploaded_file is not None:
|
| 6 |
+
# Define directory to save file
|
| 7 |
+
|
| 8 |
+
if not os.path.exists(directory):
|
| 9 |
+
os.makedirs(directory)
|
| 10 |
+
|
| 11 |
+
# Save uploaded PDF file to directory
|
| 12 |
+
with open(os.path.join(directory, uploaded_file.name), "wb") as pdf_file:
|
| 13 |
+
pdf_file.write(uploaded_file.getbuffer())
|
| 14 |
+
|
| 15 |
+
st.success(f"File '{uploaded_file.name}' saved successfully!")
|
| 16 |
+
|
| 17 |
+
|