Examplary
  • Start for free
    Developer docs

    Uploading files

    Get a file into Examplary when it isn't already available on a public URL.

    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:

    GET/media/upload?filename=chapter-3.pdf&contentType=application/pdf&type=source-material
    ParameterDescription
    filenameThe file's name, such as chapter-3.pdf.
    contentTypeThe file's content type, such as application/pdf.
    typeWhat 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.pdf

    Once the upload has finished, use the publicUrl wherever the API asks for the file's URL.

    Uploaded files are public

    Anyone with the publicUrl can open the file, so don't share it beyond your own systems.