I work with a standard Yesod scaffolding project.
I created a page that displays a simple form for uploading files.
(The form is likely to be created on the client using Javascript.)
For brevity, the form has one input file:
<form method="post" action=@{UploadR}>
<input type="file" name="myfile">
<button type="submit">
My task is to process the form data and then upload the file to the web service.
I have no problem processing the form; my problem is with the web service.
For example, given the following Yesod handler:
postUploadR :: Handler Html
postUploadR = do
mgr <- fmap httpManager getYesod
fi <- runInputPost $ ireq fileField "myfile"
let fSource = fileSource fi
fName = fileName fi
req <- parseUrl "http://webservice/upload"
let areq = req { method = methodPost
, requestBody = requestBodySourceChunked fSource
}
res <- httpLbs areq mgr
defaultLayout $ do
setTitle "file uploaded"
[whamlet|
<h3> Success
<p> You uploaded
|]
Webservice returns an error: fail post content-lengthbut everything else works as expected. Perhaps the server does not support a piece of request?