I'm confused about the use of returnBlob. I was looking through the existing urweb demos to see how I could access the data in a blob of mime type "text/plain" as a string. Eventually, I want to import into a table from a CSV file the user uploads.
I hoped that returnBlob used in a transaction string could achieve
this. So I modified demo/upload.ur to
fun echo (r : {File : file}) : transaction string =
if blobSize (fileData r.File) > 100000 then
return "Whoa! That one's too big."
else
returnBlob (fileData r.File) (blessMime (fileMimeType r.File))
fun echoLength (r : {File : file}) : transaction page =
s <- echo r ;
return <xml>{[String.length s]}</xml>
fun main () : transaction page
= return <xml><body>
<h1>The Amazing File Echoer!</h1>
<form>Upload a file: <upload{#File}/> <submit action={echoLength}/></form>
</body></xml>
This compiles and runs, and when I supply a file longer than 100000 I
get the expected page with the result 26, but to my surprise a shorter
file results in a page with the content of the file not it's length.
I'd really appreciate some help.
Thanks in advance and best regards,
Marko
pgp_OHlaRGLdJ.pgp
Description: OpenPGP Digital Signature
_______________________________________________ Ur mailing list [email protected] http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
