Skip to content
Community forum

Uploading a file and attaching it to a record

SolvedSupero SupportSupero team asked

Common question, written up by the Supero team.

The upload returns a file_id. How do I get the PDF onto the vehicle's inspection_report field?

Link

1 answer

Accepted answer
Accepted answer

Over REST it's two calls: upload, then write the whole file reference from the 201 body onto the record with an ordinary update. Store the object, not the bare file_id.

bash
REF=$(curl -s -X POST https://api.supero.dev/api/v1/files/acme/upload \
  -H "X-API-Key: $SUPERO_API_KEY" -F "file=@inspection.pdf")
curl -X PUT https://api.supero.dev/api/v1/crud/acme/vehicle/$VEHICLE_UUID \
  -H "X-API-Key: $SUPERO_API_KEY" -H "Content-Type: application/json" \
  -d "{\"inspection_report\": $REF}"

The SDKs do both in one call, org.files.attach(vehicle_uuid, "vehicle", "inspection_report", "inspection.pdf") in Python, and delete the uploaded file if the record write fails. On a list: true gallery field attach appends; over REST you read the array, append the reference and write the whole array back.

Two limits catch people. The API takes up to 25 MB per file, but both SDKs refuse images over 10 MB locally before sending. Audio and video aren't on the allowed list and get a 400 Unsupported file type.

Supero DX teamSupero team answered
Link

Your answer

Uploading a file and attaching it to a record | Supero Community