From 9e674556c54114d17c6c349a0f58df14091ae4a7 Mon Sep 17 00:00:00 2001 From: Ye Ji Date: Sun, 25 Jan 2015 21:17:19 -0500 Subject: [PATCH 1/2] Add support for prefix + delimiter style listObjects request that returns a list of CommonPrefixes --- Network/AWS/S3Bucket.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Network/AWS/S3Bucket.hs b/Network/AWS/S3Bucket.hs index 336cd44..3eab062 100644 --- a/Network/AWS/S3Bucket.hs +++ b/Network/AWS/S3Bucket.hs @@ -219,6 +219,9 @@ data ListResult = etag :: String, -- ^ MD5 size :: Integer, -- ^ Bytes of object data storageClass :: StorageClass -- ^ Storage class of the object + } + | CommonPrefix { + keyPrefix :: String } deriving (Show) -- | Is a result set response truncated? @@ -291,13 +294,17 @@ getListResults :: String -> IO [ListResult] getListResults s = runX (readString [withValidate no] s >>> processListResults) processListResults :: ArrowXml a => a (Data.Tree.NTree.TypeDefs.NTree XNode) ListResult -processListResults = deep (isElem >>> hasName "Contents") >>> +processListResults = (deep (isElem >>> hasName "Contents") >>> ((text <<< atTag "Key") &&& (text <<< atTag "LastModified") &&& (text <<< atTag "ETag") &&& (text <<< atTag "Size") &&& (text <<< atTag "StorageClass")) >>> - arr (\(a,(b,(c,(d,e)))) -> ListResult a b ((unquote . HTTP.urlDecode) c) (read d) (read e)) + arr (\(a,(b,(c,(d,e)))) -> ListResult a b ((unquote . HTTP.urlDecode) c) (read d) (read e))) + <+> + (deep (isElem >>> hasName "CommonPrefixes") >>> + (text <<< atTag "Prefix") >>> + arr (\a -> CommonPrefix a)) -- | Check Amazon guidelines on bucket naming. (missing test for IP-like names) isBucketNameValid :: String -> Bool From b374f675b2dd9585c8c1329b7129caa90351f413 Mon Sep 17 00:00:00 2001 From: Ye Ji Date: Tue, 27 Jan 2015 13:03:24 -0500 Subject: [PATCH 2/2] bump version for personal project --- hS3.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hS3.cabal b/hS3.cabal index e8a0595..ce4cc87 100644 --- a/hS3.cabal +++ b/hS3.cabal @@ -1,5 +1,5 @@ Name: hS3 -Version: 0.5.9 +Version: 0.5.10 License: BSD3 License-file: LICENSE Cabal-Version: >= 1.6