Mercurial > urweb
annotate tests/dbupload.ur @ 2166:8a01e8f21de9
Make OpenSSL usage thread-safe (closes #206)
Enable OpenSSL?s multithreading support by defining locking and
thread-ID callbacks. Remove a lock obviated by this change.
author | Benjamin Barenblat <bbaren@mit.edu> |
---|---|
date | Thu, 06 Aug 2015 10:15:53 -0400 |
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 |