Reputation: 167
I am trying to display a pipeline script on the UI with streamlit and facing this error AttributeError: 'NoneType' object has no attribute 'name'
My code is as follow
data_file = st.file_uploader("Upload raw file", type=["docx"])
with open(os.path.join("/home/lungsang/Desktop/levelpack-UI/content/A0/1 docx-raw", data_file.name),
"wb") as f:
f.write(data_file.getbuffer())
If you guys know how to avoid this small error showing on the UI, please do share here, it would help alot:)
Upvotes: 0
Views: 1442
Reputation: 5721
Put data_file to a condition of if statement
data_file = st.file_uploader("Upload raw file", type=["docx"])
if data_file is not None: # Added missing if statement
with open(os.path.join("/home/lungsang/Desktop/levelpack-UI/content/A0/1 docx-raw", data_file.name),
"wb") as f:
f.write(data_file.getbuffer())
Upvotes: 1