Resumable Uploads
6 min
resumable uploads litmus edge uses a three step resumable upload pattern for any operation that ingests a file templates, backups, certificates, analytics models the pattern is the same; only the path changes the pattern phase method what it does body 0 clear delete remove any incomplete/stale upload session none 1 create session post declare file size, get a session id back {"size" \<bytes>} 2 upload put stream the file bytes into the session binary file body why delete first? if a previous upload was interrupted (network drop, browser close), the session persists on the server deleting it first ensures a clean state and prevents 409 conflict endpoints that use it workflow base path page apply / upload template /dm/template/v2 workflow 1 # restore backup /dm/backup/v2 workflow 2 # upload custom ca /dm/certstore (no delete step) workflow 3 # upload analytics model /analytics/v2/upload model/v2 workflow 4 # step 2 (put) url shapes the put url is slightly different per module module put url shape template /dm/template/v2/{session id}/resume backup /dm/backup/v2/{session id}/resume cert store /dm/certstore/{session id} (no /resume suffix) analytics model /analytics/v2/upload model/v2/resume/{session id} example apply a template \# step 0 clear any stale session curl x delete "$edge/dm/template/v2" \\ h "authorization bearer $token" \# step 1 declare size size=$(stat c%s mytemplate zip) id=$(curl sx post "$edge/dm/template/v2" \\ h "authorization bearer $token" \\ h "content type application/json" \\ d "{\\"size\\" $size}" | jq r id) \# step 2 upload bytes curl x put "$edge/dm/template/v2/$id/resume" \\ h "authorization bearer $token" \\ \ data binary @mytemplate zip lem uploads are different lem does not use this pattern lem ml model upload uses a pre signed s3 url post /mlmodel/{filename}/upload url returns a signed s3 url put \<signed url> uploads bytes directly to s3 (no auth header needed sigv4 is baked into the url) post /mlmodel/{filename} commits / registers the model in lem see upload ai/ml model to lem #