Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for prefix + delimiter style listObjects request #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Network/AWS/S3Bucket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hS3.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: hS3
Version: 0.5.9
Version: 0.5.10
License: BSD3
License-file: LICENSE
Cabal-Version: >= 1.6
Expand Down