Finalize storage code
Browse files- README.md +1 -1
- app.py +4 -3
- modules/storage.py +3 -5
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: 🐢
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: green
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 5.
|
8 |
python_version: 3.12.8
|
9 |
license: apache-2.0
|
10 |
app_file: app.py
|
|
|
4 |
colorFrom: yellow
|
5 |
colorTo: green
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.29.0
|
8 |
python_version: 3.12.8
|
9 |
license: apache-2.0
|
10 |
app_file: app.py
|
app.py
CHANGED
@@ -126,7 +126,8 @@ with gr.Blocks(css_paths="style_20250503.css", title="3D viewer", theme='Surn/be
|
|
126 |
value=default_folder,
|
127 |
elem_id="folder_name",
|
128 |
key="folder_name",
|
129 |
-
placeholder="Enter folder name..."
|
|
|
130 |
)
|
131 |
permalink_button = gr.Button("Generate Permalink", elem_id="permalink_button", key="permalink_button", elem_classes="solid small centered")
|
132 |
|
@@ -136,11 +137,11 @@ with gr.Blocks(css_paths="style_20250503.css", title="3D viewer", theme='Surn/be
|
|
136 |
label="Permalink",
|
137 |
elem_id="permalink",
|
138 |
key="permalink",
|
139 |
-
elem_classes="solid
|
140 |
max_lines=5,
|
141 |
lines=3
|
142 |
)
|
143 |
-
gr.Markdown("### Copy the link above to share your model and images.")
|
144 |
with gr.Row():
|
145 |
gr.HTML(value=getVersions(), visible=True, elem_id="versions")
|
146 |
|
|
|
126 |
value=default_folder,
|
127 |
elem_id="folder_name",
|
128 |
key="folder_name",
|
129 |
+
placeholder="Enter folder name...",
|
130 |
+
elem_classes="solid centered"
|
131 |
)
|
132 |
permalink_button = gr.Button("Generate Permalink", elem_id="permalink_button", key="permalink_button", elem_classes="solid small centered")
|
133 |
|
|
|
137 |
label="Permalink",
|
138 |
elem_id="permalink",
|
139 |
key="permalink",
|
140 |
+
elem_classes="solid centered",
|
141 |
max_lines=5,
|
142 |
lines=3
|
143 |
)
|
144 |
+
gr.Markdown("### Copy the link above to share your model and images.", elem_classes="solid centered",)
|
145 |
with gr.Row():
|
146 |
gr.HTML(value=getVersions(), visible=True, elem_id="versions")
|
147 |
|
modules/storage.py
CHANGED
@@ -32,7 +32,7 @@ def upload_files_to_repo(files, repo_id, folder_name, create_permalink=False, re
|
|
32 |
valid_files = []
|
33 |
|
34 |
# Ensure folder_name does not have a trailing slash.
|
35 |
-
folder_name = folder_name.rstrip("/")
|
36 |
|
37 |
# Filter for valid files based on allowed extensions.
|
38 |
for f in files:
|
@@ -46,13 +46,11 @@ def upload_files_to_repo(files, repo_id, folder_name, create_permalink=False, re
|
|
46 |
if not valid_files:
|
47 |
return [] # or raise an exception
|
48 |
|
49 |
-
# Create a temporary directory
|
50 |
with tempfile.TemporaryDirectory() as temp_dir:
|
51 |
-
target_dir = os.path.join(temp_dir, folder_name)
|
52 |
-
os.makedirs(target_dir, exist_ok=True)
|
53 |
for file_path in valid_files:
|
54 |
filename = os.path.basename(file_path)
|
55 |
-
dest_path = os.path.join(
|
56 |
shutil.copy(file_path, dest_path)
|
57 |
|
58 |
# Batch upload all files in the temporary folder.
|
|
|
32 |
valid_files = []
|
33 |
|
34 |
# Ensure folder_name does not have a trailing slash.
|
35 |
+
folder_name = folder_name.rstrip("/")
|
36 |
|
37 |
# Filter for valid files based on allowed extensions.
|
38 |
for f in files:
|
|
|
46 |
if not valid_files:
|
47 |
return [] # or raise an exception
|
48 |
|
49 |
+
# Create a temporary directory; copy valid files directly into it (without using folder_name).
|
50 |
with tempfile.TemporaryDirectory() as temp_dir:
|
|
|
|
|
51 |
for file_path in valid_files:
|
52 |
filename = os.path.basename(file_path)
|
53 |
+
dest_path = os.path.join(temp_dir, filename)
|
54 |
shutil.copy(file_path, dest_path)
|
55 |
|
56 |
# Batch upload all files in the temporary folder.
|