Spaces:
Running
Running
seawolf2357
commited on
Commit
โข
5fd7cca
1
Parent(s):
377906c
Update app.py
Browse files
app.py
CHANGED
@@ -22,15 +22,20 @@ def upload_file_to_hf_space(uploaded_file):
|
|
22 |
repo_id = f"{user_id}/{space_name}"
|
23 |
|
24 |
# ์์ ํ์ผ ์์ฑ ๋ฐ ์
๋ก๋๋ ํ์ผ ๋ฐ์ดํฐ ์ฐ๊ธฐ
|
25 |
-
with tempfile.NamedTemporaryFile(delete=True, suffix='.mp4') as tmp_file:
|
26 |
-
|
|
|
27 |
tmp_file.write(uploaded_file)
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
api.upload_file(
|
35 |
path_or_fileobj=file_path,
|
36 |
path_in_repo=os.path.basename(file_path),
|
|
|
22 |
repo_id = f"{user_id}/{space_name}"
|
23 |
|
24 |
# ์์ ํ์ผ ์์ฑ ๋ฐ ์
๋ก๋๋ ํ์ผ ๋ฐ์ดํฐ ์ฐ๊ธฐ
|
25 |
+
with tempfile.NamedTemporaryFile(delete=True, suffix='.mp4', mode='wb') as tmp_file:
|
26 |
+
# ์
๋ก๋๋ ํ์ผ์ ๋ฐ์ดํธ ๋ฐ์ดํฐ๋ฅผ ์์ ํ์ผ์ ์ฐ๊ธฐ
|
27 |
+
if isinstance(uploaded_file, bytes):
|
28 |
tmp_file.write(uploaded_file)
|
29 |
+
else:
|
30 |
+
# Gradio๋ก๋ถํฐ ๋ฐ์ ํ์ผ ๋ฐ์ดํฐ๊ฐ bytes๊ฐ ์๋ ๊ฒฝ์ฐ ์ฒ๋ฆฌ
|
31 |
+
data = uploaded_file.read() # ํ์ผ ๊ฐ์ฒด์์ ๋ฐ์ดํธ ๋ฐ์ดํฐ ์ฝ๊ธฐ
|
32 |
+
tmp_file.write(data)
|
33 |
+
|
34 |
+
tmp_file.flush()
|
35 |
+
file_path = tmp_file.name
|
36 |
+
|
37 |
+
logging.info(f"Uploading {file_path} to Hugging Face Spaces")
|
38 |
+
try:
|
39 |
api.upload_file(
|
40 |
path_or_fileobj=file_path,
|
41 |
path_in_repo=os.path.basename(file_path),
|