File size: 852 Bytes
7e6ee3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
from pathlib import Path
from utils.cloudinary_uploader import upload_file


def main():
    uploads_dir = Path(__file__).resolve().parents[1] / "uploads"
    if not uploads_dir.exists():
        print(f"Uploads directory not found: {uploads_dir}")
        return

    uploaded = 0
    for path in uploads_dir.rglob("*"):
        if not path.is_file():
            continue
        try:
            result = upload_file(str(path), folder="examcraft/legacy_uploads")
            if result and result.get("url"):
                uploaded += 1
                print(f"Uploaded: {path} -> {result.get('url')}")
            else:
                print(f"Skipped (no config?): {path}")
        except Exception as e:
            print(f"Failed: {path} ({e})")

    print(f"Done. Uploaded {uploaded} files.")


if __name__ == "__main__":
    main()