Send files to an endpoint, and get files back
An endpoint can take files, such as a photo to pin or a document to keep, and can answer with a file: a PDF, a picture, an SVG chart or a CSV.
Open Endpoint (API Maker)Steps
- Make an endpoint from something that takes a file, such as Pinstant's Pin a file or Ocaltio's Save a file. In the list of what an app can do, With files shows only those.
- Under What the caller sends, name the field the caller sends the file in, such as photo. Under Speed and history, set the largest file you accept.
- To answer with a file, choose What comes back: The file it made when the answer names a file (such as Turn HTML into a PDF), As the app sends it for pictures and charts, or As CSV for a list.
- Tick Make browsers save it as a download if it should download rather than open.
- Try it from the endpoint's Playground: choose a file and press Call it. Pictures and PDFs show right there.
Examples
curl: send a file
curl -X POST https://endpoint.ocalt.com/your-endpoint-address \
-F "photo=@./holiday.jpg"
curl: get a PDF
curl -X POST https://endpoint.ocalt.com/your-endpoint-address \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Invoice 12</h1>"}' \
-o invoice.pdf