Streaming from S3 Bucket Using Amazonka with Servant

I would like to be able to transfer the contents of the contents of the S3 bucket through Servant as the response body.

I am having problems with an instance of MonadResource instance for Handler:

src/Servant/Streaming/Example.hs:29:3: error:
    * No instance for (MonadResource Handler)
        arising from a use of `runAWS'
    * In a stmt of a 'do' block: runAWS env conduits
      In the expression:
        do env <- newEnv Discover
           runAWS env conduits
      In an equation for `server':
          server
            = do env <- newEnv Discover
                 runAWS env conduits
   |
29 |   runAWS env conduits
   |   ^^^^^^^^^^^^^^^^^^^

I created a repository for playback: https://github.com/domenkozar/servant-streaming-amazonka

servant-streaming-serverprocesses ResourceTfor Stream (Of BS.ByteString) (ResourceT IO) () https://github.com/plow-technologies/servant-streaming/blob/master/servant-streaming-server/src/Servant/Streaming/Server/Internal.hs#L77-L79

but since I use Amazonka, I also need to make sure that the MonadResource for the handler is taken in this bracket. It’s not clear to me how to do this.

, enter/hoistServer , ( ).

:

  • EDIT: $$ $$+-
  • EDIT2: , MonadResource
+4
1

server :: Server API
server =  do
  env <- newEnv Discover
  res <- runInternalState (runAWS env conduits) st
  return (res >> liftIO (closeInternalState st))

https://github.com/domenkozar/servant-streaming-amazonka/commit/c5fad78dd7bf733cecb8790035105c819d5f5ae9

0

Source: https://habr.com/ru/post/1695002/


All Articles