Example for the 'script_raw' functionality where a script can send output directly to the browser.

pull/7/head
Ferry Boender 10 years ago
parent 18394194dd
commit 5eed3e1466
  1. 6
      examples/raw/README.md
  2. 11
      examples/raw/job_large_bin.sh
  3. 8
      examples/raw/job_show_image.sh
  4. 21
      examples/raw/raw.json
  5. BIN
      examples/raw/test.jpg

@ -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.

@ -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

@ -0,0 +1,8 @@
#!/bin/sh
cat << EOF
HTTP/1.0 200 Ok
Content-Type: image/jpeg
EOF
cat test.jpg

@ -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": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Loading…
Cancel
Save