Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,16 +4,13 @@ import os
|
|
4 |
UPLOAD_DIR = "uploads"
|
5 |
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
6 |
|
|
|
7 |
def save_file(file):
|
8 |
if file is None:
|
9 |
return "❌ No file received."
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
# file.value is the bytes content of the uploaded file
|
14 |
-
with open(file_path, "wb") as f:
|
15 |
-
f.write(file.value)
|
16 |
-
|
17 |
return f"✅ File `{file.name}` uploaded successfully!"
|
18 |
|
19 |
with gr.Blocks() as demo:
|
|
|
4 |
UPLOAD_DIR = "uploads"
|
5 |
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
6 |
|
7 |
+
|
8 |
def save_file(file):
|
9 |
if file is None:
|
10 |
return "❌ No file received."
|
11 |
|
12 |
+
dest_path = os.path.join(UPLOAD_DIR, file.name)
|
13 |
+
shutil.copy(file.path, dest_path) # file.path is the temp file on disk
|
|
|
|
|
|
|
|
|
14 |
return f"✅ File `{file.name}` uploaded successfully!"
|
15 |
|
16 |
with gr.Blocks() as demo:
|