pktpaulie commited on
Commit
17ba637
·
verified ·
1 Parent(s): c924fdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -16,12 +16,23 @@ st.write("System PATH:", os.environ['PATH'])
16
 
17
 
18
  # Helper function to save uploaded files temporarily and return their paths
19
- def save_uploaded_file(uploaded_file):
20
- file_path = os.path.join("/tmp", uploaded_file.name)
21
- with open(file_path, "wb") as f:
22
- f.write(uploaded_file.getbuffer())
 
 
 
 
 
23
  return file_path
24
 
 
 
 
 
 
 
25
  # Custom CSS for styling
26
  st.markdown("""
27
  <style>
 
16
 
17
 
18
  # Helper function to save uploaded files temporarily and return their paths
19
+ def save_uploaded_file(content):
20
+ if hasattr(content, 'name'): # Check if it's a file-like object
21
+ file_path = os.path.join("/tmp", content.name)
22
+ with open(file_path, "wb") as f:
23
+ f.write(content.read())
24
+ else: # It's a string (the file contents)
25
+ file_path = os.path.join("/tmp", "temp_upload")
26
+ with open(file_path, "w") as f:
27
+ f.write(str(content))
28
  return file_path
29
 
30
+ # def save_uploaded_file(uploaded_file):
31
+ # file_path = os.path.join("/tmp", uploaded_file.name)
32
+ # with open(file_path, "wb") as f:
33
+ # f.write(uploaded_file.getbuffer())
34
+ # return file_path
35
+
36
  # Custom CSS for styling
37
  st.markdown("""
38
  <style>