diff options
Diffstat (limited to 'GetObject.hs')
-rw-r--r-- | GetObject.hs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/GetObject.hs b/GetObject.hs new file mode 100644 index 000000000..51764bf72 --- /dev/null +++ b/GetObject.hs @@ -0,0 +1,24 @@ +{-# 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) + +main :: IO () +main = do + {- Set up AWS credentials and the default configuration. -} + Just creds <- Aws.loadCredentialsFromEnv + let cfg = Aws.Configuration Aws.Timestamp creds (Aws.defaultLog Aws.Debug) + 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. -} + S3.GetObjectResponse { S3.gorResponse = rsp } <- + Aws.pureAws cfg s3cfg mgr $ + S3.getObject "joeyh-test" "cloud-remote.pdf" + + {- Save the response to a file. -} + responseBody rsp $$+- sinkFile "cloud-remote2.pdf" |