aws-simple 0.1.0.0 → 0.3.0.0
raw patch · 5 files changed
+45/−17 lines, 5 filesdep +unordered-containersdep ~amazonka
Dependencies added: unordered-containers
Dependency ranges changed: amazonka
Files
- LICENSE +1/−1
- aws-simple.cabal +6/−5
- package.yaml +5/−4
- src/Network/AWS/Simple.hs +24/−6
- stack.yaml +9/−1
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2016 Alexander Thiemann+Copyright (c) 2016 - 2017 Alexander Thiemann Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
aws-simple.cabal view
@@ -1,16 +1,16 @@--- This file has been generated from package.yaml by hpack version 0.14.0.+-- This file has been generated from package.yaml by hpack version 0.15.0. -- -- see: https://github.com/sol/hpack name: aws-simple-version: 0.1.0.0+version: 0.3.0.0 synopsis: Dead simple bindings to commonly used AWS Services-description: Please see README.md+description: Simple bindings to commonly used AWS services category: Web homepage: https://github.com/agrafix/aws-simple#readme author: Alexander Thiemann maintainer: mail@athiemann.net-copyright: 2016 Alexander Thiemann <mail@athiemann.net>+copyright: 2016 - 2017 Alexander Thiemann <mail@athiemann.net> license: MIT license-file: LICENSE build-type: Simple@@ -32,11 +32,12 @@ , resourcet , lens , conduit- , amazonka+ , amazonka >= 1.4.5 , amazonka-core , amazonka-s3 , amazonka-sqs , blaze-builder+ , unordered-containers exposed-modules: Network.AWS.Simple other-modules:
package.yaml view
@@ -1,12 +1,12 @@ name: aws-simple-version: 0.1.0.0+version: 0.3.0.0 synopsis: Dead simple bindings to commonly used AWS Services-description: Please see README.md+description: Simple bindings to commonly used AWS services homepage: https://github.com/agrafix/aws-simple#readme license: MIT author: Alexander Thiemann maintainer: mail@athiemann.net-copyright: 2016 Alexander Thiemann <mail@athiemann.net>+copyright: 2016 - 2017 Alexander Thiemann <mail@athiemann.net> category: Web extra-source-files: - README.md@@ -21,11 +21,12 @@ - resourcet - lens - conduit- - amazonka+ - amazonka >= 1.4.5 - amazonka-core - amazonka-s3 - amazonka-sqs - blaze-builder+ - unordered-containers library: source-dirs: src
src/Network/AWS/Simple.hs view
@@ -1,11 +1,13 @@ {-# LANGUAGE OverloadedStrings #-} module Network.AWS.Simple ( connectAWS, AWSHandle+ , AWS.Region (..) -- * Logging , AWS.LogLevel (..), LogFun -- * S3 , AWSFileReadability(..) , s3Upload, s3Download, s3Delete, s3CopyInBucket+ , s3MetaData -- * SQS , sqsGetQueue, AWSQueue , sqsSendMessage@@ -19,6 +21,7 @@ import Control.Monad.Trans import Control.Monad.Trans.Resource import Data.Conduit+import Data.HashMap.Strict (HashMap) import Data.Int import Data.Maybe import Data.Monoid@@ -37,13 +40,13 @@ type LogFun = AWS.LogLevel -> BS.ByteString -> IO () -connectAWS :: LogFun -> IO AWSHandle-connectAWS logF =+connectAWS :: AWS.Region -> LogFun -> IO AWSHandle+connectAWS reg logF = AWSHandle <$> hdl where hdl =- do x <- AWS.newEnv AWS.Frankfurt AWS.Discover- pure (x & AWS.envLogger .~ mkLogFun logF)+ do x <- AWS.newEnv AWS.Discover+ pure (x & AWS.envLogger .~ mkLogFun logF & AWS.envRegion .~ reg ) mkLogFun :: LogFun -> AWS.Logger mkLogFun f ll logBuilder=@@ -58,18 +61,33 @@ | AWSFilePrivate deriving (Show, Eq, Enum, Bounded) +s3MetaData ::+ AWSHandle+ -> T.Text+ -> T.Text+ -> IO (HashMap T.Text T.Text)+s3MetaData hdl bucket objName =+ runAWS hdl $+ do rs <- AWS.send ho+ pure $ view S3.horsMetadata rs+ where+ ho = S3.headObject (S3.BucketName bucket) (S3.ObjectKey objName)+ s3Upload :: AWSHandle -> AWSFileReadability+ -> HashMap T.Text T.Text -> T.Text -> T.Text -> Int64 -> Source (ResourceT IO) BS.ByteString -> IO ()-s3Upload hdl readability bucket objName size fileSource =+s3Upload hdl readability metaData bucket objName size fileSource = runAWS hdl $ do contentHash <- lift $ fileSource $$ AWS.sinkSHA256 let body = AWS.HashedStream contentHash (fromIntegral size) fileSource- po = S3.putObject (S3.BucketName bucket) (S3.ObjectKey objName) (AWS.Hashed body)+ po =+ (S3.putObject (S3.BucketName bucket) (S3.ObjectKey objName) (AWS.Hashed body))+ & S3.poMetadata .~ metaData poACL = case readability of AWSFilePrivate -> po
stack.yaml view
@@ -1,3 +1,11 @@-resolver: lts-7.9+resolver: lts-7.15 packages: - .+extra-deps:+ - http-client-0.5.5+ - http-client-tls-0.3.3.1+ - http-conduit-2.2.3+ - amazonka-core-1.4.5+ - amazonka-1.4.5+ - amazonka-s3-1.4.5+ - amazonka-sqs-1.4.5