API endpoints that work with files, such as creating a source material, take the file as a URL. Any public HTTPS URL works, and Examplary keeps its own copy of the file, so the original link doesn't have to stay online.
If your file isn't online, upload it to Examplary first. That takes two requests: one to get an upload URL, and one to send the file to it.
Step 1: Get an upload URL
Ask for an upload URL, passing the file's name, its content type, and what the file is for:
| Parameter | Description |
|---|---|
filename | The file's name, such as chapter-3.pdf. |
contentType | The file's content type, such as application/pdf. |
type | What the file is for, such as source-material. Used to group your uploads. |
This returns an uploadUrl to send the file to, and the publicUrl it will be available at:
{
"uploadUrl": "https://…",
"publicUrl": "https://examcdn.com/…/chapter-3.pdf"
}Step 2: Upload the file
Send the file with a PUT request to the uploadUrl. Use the raw file as the body, not a form, and set the same Content-Type you asked for in step 1, or the upload is rejected. The upload URL is valid for an hour.
curl -X PUT "$UPLOAD_URL" \
-H "Content-Type: application/pdf" \
--data-binary @chapter-3.pdfOnce the upload has finished, use the publicUrl wherever the API asks for the file's URL.
Anyone with the publicUrl can open the file, so don't share it beyond your own systems.