[Haskell-cafe] Happstack: moving the uploaded file

Nikita Karetnikov nikita at karetnikov.org
Mon Jun 2 20:31:14 UTC 2014


I’m trying to create a trivial Happstack application based on the
example from the “File Uploads” section of the Happstack book [1].  
It should work as follows:

1. If there is no file called ‘foo’ on disk, show the upload form at any
   page.

2. If the file exists, show its contents at ‘localhost:8000/file’ and
   the upload form at any other page.

The difficulty is that initially the uploaded file is placed to a
temporary location, but since I want to read the file later, I have to
move it somewhere.  ‘UploadFile-working.hs’ uses two handlers for that,
which doesn’t look right.  I’d like the code to look like
‘UploadFile.hs’, but it doesn’t work properly.  Could anyone explain
why?

[1] http://happstack.com/docs/crashcourse/index.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: UploadFile-working.hs
Type: text/x-haskell
Size: 1694 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140603/64b0fb37/attachment.hs>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: UploadFile.hs
Type: text/x-haskell
Size: 1265 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140603/64b0fb37/attachment-0001.hs>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140603/64b0fb37/attachment.sig>


More information about the Haskell-Cafe mailing list