Skip to content

Instantly share code, notes, and snippets.

@aristidb
Created September 23, 2012 14:16
Show Gist options
  • Save aristidb/3771425 to your computer and use it in GitHub Desktop.
Save aristidb/3771425 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
import qualified Aws
import qualified Aws.S3 as S3
import Data.Conduit (($$+-))
import Data.Conduit.Binary (sinkFile)
import Network.HTTP.Conduit (withManager, responseBody)
import Control.Monad.IO.Class
main :: IO ()
main = do
{- Set up AWS credentials and the default configuration. -}
putStrLn "Set up AWS credentials and the default configuration."
cfg <- Aws.dbgConfiguration
let s3cfg = Aws.defServiceConfig :: S3.S3Configuration Aws.NormalQuery
{- Set up a ResourceT region with an available HTTP manager. -}
withManager $ \mgr -> do
{- Create a request object with S3.getObject and run the request with pureAws. -}
liftIO $ putStrLn "Create a request object with S3.getObject and run the request with pureAws."
S3.GetObjectResponse { S3.gorResponse = rsp } <-
Aws.pureAws cfg s3cfg mgr $
S3.getObject "haskell-aws" "cloud-remote.pdf"
{- Save the response to a file. -}
liftIO $ putStrLn "Save the response to a file."
responseBody rsp $$+- sinkFile "cloud-remote.pdf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment