Upload files
Put files from disk on a canvas, up to 50 at a time.
List each file's name, type, size and base64 SHA-256 in
upload_start, send each one to its link, then
call upload_finish.
import base64, hashlib, os, requests
API = "https://api.fuser.studio/v1"
HEADERS = {"x-api-key": os.environ["FUSER_API_KEY"]}
paths = ["front.jpg", "back.jpg"]
files = [{
"fileName": os.path.basename(p),
"contentType": "image/jpeg",
"size": os.path.getsize(p),
"sha256": base64.b64encode(hashlib.sha256(open(p, "rb").read()).digest()).decode(),
} for p in paths]
start = requests.post(f"{API}/upload_start", headers=HEADERS,
json={"canvasId": CANVAS_ID, "files": files}).json()
for path, file in zip(paths, start["files"]):
if file["status"] == "upload":
requests.put(file["url"], headers=file["headers"], data=open(path, "rb"))
done = requests.post(f"{API}/upload_finish", headers=HEADERS,
json={"uploadId": start["uploadId"]}).json()
print([f.get("url") for f in done["files"]])Files Fuser already has come back as done straight away. Use the returned
links as an ImageNode or VideoNode input.