diff tests/blob.ur @ 737:d049d31a1966

Initial support for blobs and upload
author Adam Chlipala <adamc@hcoop.net>
date Sat, 25 Apr 2009 13:59:11 -0400
parents
children 4bb7e1c0550a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/blob.ur	Sat Apr 25 13:59:11 2009 -0400
@@ -0,0 +1,22 @@
+sequence s
+table t : { Id : int, Nam : option string, Data : blob, Desc : string }
+
+fun save r =
+    if numFiles r.Data <> 1 then
+        error <xml>Please submit exactly one file.</xml>
+    else
+        let
+            val f = fileNum r.Data 0
+        in
+            id <- nextval s;
+            dml (INSERT INTO t (Id, Nam, Data, Desc) VALUES ({[id]}, {[fileName f]}, {[fileData f]}, {[r.Desc]}));
+            main ()
+        end
+
+and main () = return <xml><body>
+  <form>
+    <textbox{#Desc}/>
+    <upload{#Data}/>
+    <submit action={save}/>
+  </form>
+</body></xml>