aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/dbupload2.ur
diff options
context:
space:
mode:
authorGravatar Sergey Mironov <grrwlf@gmail.com>2014-08-15 07:11:31 +0000
committerGravatar Sergey Mironov <grrwlf@gmail.com>2014-08-15 07:11:31 +0000
commit1ef54c4722223a52f0b57bf0407cff39ebeb9f62 (patch)
tree0d64a8971e731187b8a0743de34b4bc57f5c11e4 /tests/dbupload2.ur
parentfd4d68a8483496bcb52c87a2e0c37cc92e5e6774 (diff)
Add tests/dbupload2.* files
tests/dbupload2.sh is a shell script which run the test scenario On my machine the executable segfaults after curl request
Diffstat (limited to 'tests/dbupload2.ur')
-rw-r--r--tests/dbupload2.ur29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/dbupload2.ur b/tests/dbupload2.ur
new file mode 100644
index 00000000..428f2460
--- /dev/null
+++ b/tests/dbupload2.ur
@@ -0,0 +1,29 @@
+table t : { Id : int, Blob : blob, MimeType : string }
+sequence s
+
+fun getImage id : transaction page =
+ r <- oneRow1 (SELECT t.Blob, t.MimeType
+ FROM t
+ WHERE t.Id = {[id]});
+ returnBlob r.Blob (blessMime r.MimeType)
+
+fun handle (r : {File:file, Param:string}) =
+ id <- nextval s;
+ dml (INSERT INTO t (Id, Blob, MimeType)
+ VALUES ({[id]}, {[fileData r.File]}, {[fileMimeType r.File]}));
+ debug ("Text is " ^ r.Param);
+ main ()
+
+and main () : transaction page =
+ x <- queryX1 (SELECT t.Id FROM t)
+ (fn r => <xml><img src={url (getImage r.Id)}/>
+</xml>);
+ return <xml><body>
+ <form>
+ <upload{#File}/>
+ <textbox{#Param} value="text"/>
+ <submit action={handle}/>
+ </form>
+ <hr/>
+ {x}
+ </body></xml>