notebook
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
TOKEN = "13e1bb01-9fd5-44a8-8ce9-4ee27133d340"
|
||||
UPLOAD_URL = "https://msgs.buzalka.cz/upload-dropbox"
|
||||
SOURCE_DIR = Path(r"C:\Users\vbuzalka\OneDrive - JNJ\##JNJPrenos")
|
||||
|
||||
files = [f for f in SOURCE_DIR.iterdir() if f.is_file()]
|
||||
|
||||
if not files:
|
||||
print("Žádné soubory k odeslání.")
|
||||
else:
|
||||
for f in files:
|
||||
try:
|
||||
with f.open("rb") as fh:
|
||||
resp = requests.post(
|
||||
UPLOAD_URL,
|
||||
headers={"Authorization": f"Bearer {TOKEN}"},
|
||||
files={"file": (f.name, fh, "application/octet-stream")},
|
||||
timeout=120,
|
||||
)
|
||||
resp.raise_for_status()
|
||||
result = resp.json()
|
||||
print(f" {result['status'].upper():10} | {f.name}")
|
||||
f.unlink()
|
||||
except Exception as e:
|
||||
print(f" CHYBA | {f.name} | {e}")
|
||||
|
||||
print("\nHotovo.")
|
||||
Reference in New Issue
Block a user