hS3 0.5.7 → 0.5.8
raw patch · 6 files changed
+41/−5 lines, 6 files
Files
- CONTRIBUTORS +1/−0
- FEATURES +1/−1
- Network/AWS/Authentication.hs +1/−0
- Network/AWS/S3Object.hs +16/−1
- Tests.hs +19/−0
- hS3.cabal +3/−3
CONTRIBUTORS view
@@ -1,3 +1,4 @@ - <harmen@millionmonkeys.nl> - Marc Weber <marco-oweber@gmx.de> - Anton van Straaten <anton@appsolutions.com>+- Kirk Peterson <necrobious@gmail.com>
FEATURES view
@@ -19,7 +19,7 @@ * Expiring either on a given date, or number of seconds from current time * Setting the storage class (Reduced Redundancy or Standard) for new objects * Rewrite storage class of existing objects-+ * MD5 message integrity check for sent objects (optional) Missing feature list (incomplete). We know the following features are not yet supported. Some features may be available without changing the
Network/AWS/Authentication.hs view
@@ -97,6 +97,7 @@ headersFromAction = map (\(k,v) -> case k of "Content-Type" -> Header HdrContentType v "Content-Length" -> Header HdrContentLength v+ "Content-MD5" -> Header HdrContentMD5 v otherwise -> Header (HdrCustom k) (mimeEncodeQP v)) . s3metadata
Network/AWS/S3Object.hs view
@@ -11,7 +11,7 @@ module Network.AWS.S3Object ( -- * Function Types- sendObject, copyObject, copyObjectWithReplace, getObject,+ sendObject, sendObjectMIC, copyObject, copyObjectWithReplace, getObject, getObjectInfo, deleteObject, publicUriForSeconds, publicUriUntilTime, setStorageClass, getStorageClass, rewriteStorageClass,@@ -27,8 +27,11 @@ import System.Time import Data.List.Utils import Data.List(lookup)+import Data.Digest.MD5(hash)+import Codec.Binary.Base64 (encode) import qualified Data.ByteString.Lazy.Char8 as L+import qualified Data.ByteString.Lazy as LO -- | An object that can be stored and retrieved from S3. data S3Object =@@ -109,6 +112,18 @@ obj_headers obj) (obj_data obj) PUT) return (either Left (\_ -> Right ()) res)++-- | Send data for an object, with message integrity check. This+-- version of sendObject will add an MD5 message integrity check so+-- that transmission errors will be detected, but requires the message+-- be read into memory before being sent.+sendObjectMIC :: AWSConnection -- ^ AWS connection information+ -> S3Object -- ^ Object to add to a bucket+ -> IO (AWSResult ()) -- ^ Server response+sendObjectMIC aws obj = sendObject aws obj_w_header where+ obj_w_header = obj { obj_headers = (obj_headers obj) ++ md5_header }+ md5_header = [("Content-MD5", (mkMD5 (obj_data obj)))]+ mkMD5 = encode . hash . LO.unpack -- | Create a pre-signed request URI. Anyone can use this to request -- an object until the specified date.
Tests.hs view
@@ -31,6 +31,7 @@ TestList [ TestLabel "S3 Operations Test" s3OperationsTest,+ TestLabel "S3 Message Integrity Check" s3MessageIntegrityCheckTest, TestLabel "S3 Copy Test" s3CopyTest, TestLabel "S3 Copy/Replace Test" s3CopyReplaceTest, TestLabel "S3 Location Test" s3LocationTest,@@ -82,6 +83,18 @@ testBucketGone c bucket ) +s3MessageIntegrityCheckTest =+ TestCase (+ do c <- getConn+ bucket <- testCreateBucket c+ testGetBucketLocation c bucket "US"+ let testObj = testObjectTemplate {obj_bucket = bucket}+ -- Object send+ testSendObjectMIC c testObj+ -- Object get+ testGetObject c testObj+ )+ s3LocationTest = TestCase ( do c <- getConn@@ -234,6 +247,12 @@ testSendObject :: AWSConnection -> S3Object -> IO () testSendObject c o = do r <- sendObject c o+ failOnError r ()+ (const $ assertBool "object send" True)++testSendObjectMIC :: AWSConnection -> S3Object -> IO ()+testSendObjectMIC c o =+ do r <- sendObjectMIC c o failOnError r () (const $ assertBool "object send" True)
hS3.cabal view
@@ -1,5 +1,5 @@ Name: hS3-Version: 0.5.7+Version: 0.5.8 License: BSD3 License-file: LICENSE Cabal-Version: >= 1.6@@ -28,8 +28,8 @@ examples/uploadFile.hs source-repository head- type: darcs- location: http://gregheartsfield.com/repos/hS3/+ type: git+ location: http://github.com/errge/hS3 Library