Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,20 +16,18 @@ DATASET_REPO = "kacapower/lexical-space-data"
|
|
| 16 |
THEME_FILE_NAME = "website_theme.xml"
|
| 17 |
|
| 18 |
def save_theme_to_dataset(xml_file):
|
| 19 |
-
"""Saves the uploaded XML file to the private hf dataset."""
|
| 20 |
if xml_file is None:
|
| 21 |
return "❌ Please upload an XML file first."
|
| 22 |
|
| 23 |
-
local_file = "temp_theme.xml"
|
| 24 |
-
|
| 25 |
try:
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
|
| 29 |
-
#
|
| 30 |
api = HfApi()
|
| 31 |
api.upload_file(
|
| 32 |
-
path_or_fileobj=
|
| 33 |
path_in_repo=THEME_FILE_NAME,
|
| 34 |
repo_id=DATASET_REPO,
|
| 35 |
repo_type="dataset",
|
|
|
|
| 16 |
THEME_FILE_NAME = "website_theme.xml"
|
| 17 |
|
| 18 |
def save_theme_to_dataset(xml_file):
|
| 19 |
+
"""Saves the uploaded XML file directly to the private hf dataset."""
|
| 20 |
if xml_file is None:
|
| 21 |
return "❌ Please upload an XML file first."
|
| 22 |
|
|
|
|
|
|
|
| 23 |
try:
|
| 24 |
+
# Safely get the file path whether Gradio returned a string or an object
|
| 25 |
+
file_path = xml_file if isinstance(xml_file, str) else xml_file.name
|
| 26 |
|
| 27 |
+
# Upload directly using HfApi without copying to a local temp file first
|
| 28 |
api = HfApi()
|
| 29 |
api.upload_file(
|
| 30 |
+
path_or_fileobj=file_path,
|
| 31 |
path_in_repo=THEME_FILE_NAME,
|
| 32 |
repo_id=DATASET_REPO,
|
| 33 |
repo_type="dataset",
|