summaryrefslogtreecommitdiff
path: root/tests/dbupload.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2013-09-13 10:24:10 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2013-09-13 10:24:10 -0400
commit081e9e2304f084f58ec91ae6ea278d75bc7a7d57 (patch)
tree0fb1418d845cdeac2a2910d51d39adf337d33cbe /tests/dbupload.ur
parent77df2d7165287246cb982d5a61ec92dce442b635 (diff)
Tweak Sergey's patch to work with Postgres
Diffstat (limited to 'tests/dbupload.ur')
-rw-r--r--tests/dbupload.ur25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/dbupload.ur b/tests/dbupload.ur
new file mode 100644
index 00000000..f088d63b
--- /dev/null
+++ b/tests/dbupload.ur
@@ -0,0 +1,25 @@
+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 main () : transaction page =
+ let
+ fun handle r =
+ id <- nextval s;
+ dml (INSERT INTO t (Id, Blob, MimeType)
+ VALUES ({[id]}, {[fileData r.File]}, {[fileMimeType r.File]}));
+ main ()
+ in
+ x <- queryX1 (SELECT t.Id FROM t)
+ (fn r => <xml><img src={url (getImage r.Id)}/><br/></xml>);
+ return <xml><body>
+ <form><upload{#File}/> <submit action={handle}/></form>
+ <hr/>
+ {x}
+ </body></xml>
+ end