Mercurial > urweb
comparison tests/dbupload.ur @ 1867:216a3a67ebe3
Tweak Sergey's patch to work with Postgres
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Fri, 13 Sep 2013 10:24:10 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1866:9fc086e3c95a | 1867:216a3a67ebe3 |
---|---|
1 table t : { Id : int, Blob : blob, MimeType : string } | |
2 sequence s | |
3 | |
4 fun getImage id : transaction page = | |
5 r <- oneRow1 (SELECT t.Blob, t.MimeType | |
6 FROM t | |
7 WHERE t.Id = {[id]}); | |
8 returnBlob r.Blob (blessMime r.MimeType) | |
9 | |
10 fun main () : transaction page = | |
11 let | |
12 fun handle r = | |
13 id <- nextval s; | |
14 dml (INSERT INTO t (Id, Blob, MimeType) | |
15 VALUES ({[id]}, {[fileData r.File]}, {[fileMimeType r.File]})); | |
16 main () | |
17 in | |
18 x <- queryX1 (SELECT t.Id FROM t) | |
19 (fn r => <xml><img src={url (getImage r.Id)}/><br/></xml>); | |
20 return <xml><body> | |
21 <form><upload{#File}/> <submit action={handle}/></form> | |
22 <hr/> | |
23 {x} | |
24 </body></xml> | |
25 end |