Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,13 @@ os.makedirs(UPLOAD_DIR, exist_ok=True)
|
|
7 |
def save_file(file):
|
8 |
if file is None:
|
9 |
return "Please upload a file."
|
|
|
|
|
|
|
10 |
file_path = os.path.join(UPLOAD_DIR, file.name)
|
11 |
with open(file_path, "wb") as f:
|
12 |
-
f.write(file
|
|
|
13 |
return f"✅ File `{file.name}` uploaded successfully!"
|
14 |
|
15 |
with gr.Blocks() as demo:
|
|
|
7 |
def save_file(file):
|
8 |
if file is None:
|
9 |
return "Please upload a file."
|
10 |
+
|
11 |
+
# file.name is the uploaded filename
|
12 |
+
# file is a NamedString -> use file to read content directly
|
13 |
file_path = os.path.join(UPLOAD_DIR, file.name)
|
14 |
with open(file_path, "wb") as f:
|
15 |
+
f.write(file) # just write the bytes
|
16 |
+
|
17 |
return f"✅ File `{file.name}` uploaded successfully!"
|
18 |
|
19 |
with gr.Blocks() as demo:
|