[Haskell-cafe] Happstack: moving the uploaded file
jeremy at n-heptane.com
Mon Jun 2 21:55:14 UTC 2014
You code does not work correctly because what you are trying to do
really requires three separate requests. You want the client to be
1. do a GET request to receive the form
2. do a POST request to upload the file
3. do another GET request to view the file after it has been uploaded
In UploadFile.hs you have the first two steps merged together in
uploadForm. In UploadFile-working -- you have steps 2 and 3 oddly
separated and merged at the same time.
I have created a modified version that probably does what you want.
On Mon, Jun 2, 2014 at 3:31 PM, Nikita Karetnikov <nikita at karetnikov.org> wrote:
> I’m trying to create a trivial Happstack application based on the
> example from the “File Uploads” section of the Happstack book .
> It should work as follows:
> 1. If there is no file called ‘foo’ on disk, show the upload form at any
> 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
>  http://happstack.com/docs/crashcourse/index.html
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1864 bytes
Desc: not available
More information about the Haskell-Cafe