diff --git a/examples/raw/README.md b/examples/raw/README.md new file mode 100644 index 0000000..4db2784 --- /dev/null +++ b/examples/raw/README.md @@ -0,0 +1,6 @@ +ScriptForm raw example +====================== + +Raw callbacks can be used to obtain more control over what is sent to the +user's browser. For instance, you can stream contents to the browser, send +files, show images, etc. diff --git a/examples/raw/job_large_bin.sh b/examples/raw/job_large_bin.sh new file mode 100755 index 0000000..c205a00 --- /dev/null +++ b/examples/raw/job_large_bin.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +FILESIZE=$(expr 1024 \* 1000 \* 100) +cat << EOF +HTTP/1.0 200 Ok +Content-Type: application/octet-stream +Content-Disposition: attachment; filename="large_file.dat" +Content-Length: $FILESIZE + +EOF +dd if=/dev/urandom bs=1024 count=100000 diff --git a/examples/raw/job_show_image.sh b/examples/raw/job_show_image.sh new file mode 100755 index 0000000..5cc19bb --- /dev/null +++ b/examples/raw/job_show_image.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +cat << EOF +HTTP/1.0 200 Ok +Content-Type: image/jpeg + +EOF +cat test.jpg diff --git a/examples/raw/raw.json b/examples/raw/raw.json new file mode 100644 index 0000000..fe87282 --- /dev/null +++ b/examples/raw/raw.json @@ -0,0 +1,21 @@ +{ + "title": "Raw callback examples", + "forms": { + "show_image": { + "title": "Show an image", + "description": "Shows you an image", + "submit_title": "Show", + "script": "job_show_image.sh", + "script_raw": true, + "fields": {} + }, + "large_bin": { + "title": "Download large binary file", + "description": "Download a large (100mb) binary file", + "submit_title": "Download", + "script": "job_large_bin.sh", + "script_raw": true, + "fields": {} + } + } +} diff --git a/examples/raw/test.jpg b/examples/raw/test.jpg new file mode 100644 index 0000000..3426c62 Binary files /dev/null and b/examples/raw/test.jpg differ