From 5eed3e1466cd83c6b34cf284b3d1616c66bd060e Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Mon, 30 Mar 2015 21:36:09 +0200 Subject: [PATCH] Example for the 'script_raw' functionality where a script can send output directly to the browser. --- examples/raw/README.md | 6 ++++++ examples/raw/job_large_bin.sh | 11 +++++++++++ examples/raw/job_show_image.sh | 8 ++++++++ examples/raw/raw.json | 21 +++++++++++++++++++++ examples/raw/test.jpg | Bin 0 -> 10963 bytes 5 files changed, 46 insertions(+) create mode 100644 examples/raw/README.md create mode 100755 examples/raw/job_large_bin.sh create mode 100755 examples/raw/job_show_image.sh create mode 100644 examples/raw/raw.json create mode 100644 examples/raw/test.jpg 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 0000000000000000000000000000000000000000..3426c6297f3ebf8375579d9443c03fe2976bb2fa GIT binary patch literal 10963 zcmb7qWl$ST)NX>i7YkOTXedr7PH}fi@B+nxOYq`Wytq5X-9qseZJ{B!Q=qsMEl|qk zow@hU_xF2tXJ_R(XV1>=%$}9Ug~ts5iK?QCA^->k0+gQu;Bgu78i0=WAO1_xpMZgd z@gH!ourRT3aq#ePad2_*2#5*r@QLtoaS2HYiHJ!^NJ;Pr$jHe^$e;2g|0x0fCy9=M z^CU=ukBk3Q`@h6vKY$bm2mk`mfy@9jQXo1h@bL?P9smGhpg&pr|A7VoKADJ(gNggp z3?X?cJpl~^0}}%c{fPtwprK=6l43pQ$0m~{*TG@7a;FdoEq=x#moh*psM~}*WA)g4 zk_0^w(a`^g-Y2=IuCTB%pBe>7|DRf{|I2w|lcHlh$0Xy&lGU+tC#PTz#ZD<6K%O;i zJ`<4p{kQ}mcvAMnAq7YS##zcFzxoSZ)+ zho=hk;5hInbQv+1(tW(=PMPii*aAJ{^m0z|;=MX|xmL7;$0r;V?`sGu0E9QX4BC`p zMmFLb+@u5T2Sc1o66u1L_H^m!rV*{xKPiu!QyLSsB5hl@R;oaN5so3c8V7@ABDZ*X zz$VlNNL8{X5YIo}o~|x0*tZwkM0jo31CS_z5pH=|B^hDLEVP723PK@+*^M2}NF13P zbpl^qyy&*hO^8!a+S-TUst64RRZC(6OogQtWxzMl6BpK|4bf#x3eV&r8c(e!{Rp1ZwnxQuGKMl(vVH63lD=S@q_8{ z%Ms3MZ0Ocwc#0z(c!vC{G|l!nD%$M=cq}yMl`v}w_G4;wAVKv{!R8mkZu-aXHmTn7 zQK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