annotate tests/dbupload.ur @ 2301:8d772fbf59c1

Tweak cache consolidation and choose better default.
author Ziv Scully <ziv@mit.edu>
date Fri, 20 Nov 2015 03:26:21 -0500
parents 216a3a67ebe3
children
rev   line source
adam@1867 1 table t : { Id : int, Blob : blob, MimeType : string }
adam@1867 2 sequence s
adam@1867 3
adam@1867 4 fun getImage id : transaction page =
adam@1867 5 r <- oneRow1 (SELECT t.Blob, t.MimeType
adam@1867 6 FROM t
adam@1867 7 WHERE t.Id = {[id]});
adam@1867 8 returnBlob r.Blob (blessMime r.MimeType)
adam@1867 9
adam@1867 10 fun main () : transaction page =
adam@1867 11 let
adam@1867 12 fun handle r =
adam@1867 13 id <- nextval s;
adam@1867 14 dml (INSERT INTO t (Id, Blob, MimeType)
adam@1867 15 VALUES ({[id]}, {[fileData r.File]}, {[fileMimeType r.File]}));
adam@1867 16 main ()
adam@1867 17 in
adam@1867 18 x <- queryX1 (SELECT t.Id FROM t)
adam@1867 19 (fn r => <xml><img src={url (getImage r.Id)}/><br/></xml>);
adam@1867 20 return <xml><body>
adam@1867 21 <form><upload{#File}/> <submit action={handle}/></form>
adam@1867 22 <hr/>
adam@1867 23 {x}
adam@1867 24 </body></xml>
adam@1867 25 end