Skip to content

Instantly share code, notes, and snippets.

@v0d1ch
Last active January 25, 2018 11:52
Show Gist options
  • Select an option

  • Save v0d1ch/76cf5acf55f844fa1a942545cdb4212b to your computer and use it in GitHub Desktop.

Select an option

Save v0d1ch/76cf5acf55f844fa1a942545cdb4212b to your computer and use it in GitHub Desktop.
yesod streaming
body <- getRequest
lift $ runConduitRes $ (consumeBody body) =$ sinkFile directory
where
consumeBody :: MonadIO m => YesodRequest -> ConduitM i ByteString m ()
consumeBody body = do
chunk <- liftIO $ NW.requestBody $ reqWaiRequest body
if (chunk == BS.empty)
then return ()
else do
yield chunk
consumeBody body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment