Spaces:
Running
Running
Tu Nombre commited on
Commit ·
b0159c2
1
Parent(s): da68fbf
fix upload via commit api
Browse files
main.py
CHANGED
|
@@ -190,10 +190,16 @@ CMD [\"uvicorn\", \"main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"7860\"]""
|
|
| 190 |
contenido_b64 = arc.get("contenido", "")
|
| 191 |
if not contenido_b64: continue
|
| 192 |
binario = base64.b64decode(contenido_b64)
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
)
|
| 198 |
print(f"Upload {nombre}: {r_up.status_code}", flush=True)
|
| 199 |
except Exception as e:
|
|
|
|
| 190 |
contenido_b64 = arc.get("contenido", "")
|
| 191 |
if not contenido_b64: continue
|
| 192 |
binario = base64.b64decode(contenido_b64)
|
| 193 |
+
commit_arc = {
|
| 194 |
+
"summary": f"upload {nombre}",
|
| 195 |
+
"files": [
|
| 196 |
+
{"path": f"media_{nombre}", "content": contenido_b64, "encoding": "base64"}
|
| 197 |
+
]
|
| 198 |
+
}
|
| 199 |
+
r_up = await client.post(
|
| 200 |
+
f"https://huggingface.co/api/spaces/{repo_name}/commit/main",
|
| 201 |
+
headers={"Authorization": f"Bearer {token_actual}", "Content-Type": "application/json"},
|
| 202 |
+
content=_json.dumps(commit_arc).encode()
|
| 203 |
)
|
| 204 |
print(f"Upload {nombre}: {r_up.status_code}", flush=True)
|
| 205 |
except Exception as e:
|