Add deleteBucket and deleteObject api

This commit is contained in:
Krishnan Parthasarathi 2017-01-09 17:43:44 +05:30 committed by Aditya Manthramurthy
parent 45d5f9e676
commit 2cda5d2e55
2 changed files with 33 additions and 3 deletions

View File

@ -29,13 +29,19 @@ main = do
-- Right body -> body C.$$+- CL.mapM_ putStrLn
-- body <- NC.responseBody <$> res
-- NC.responseBody res C.$$+- CL.mapM_ putStrLn
res <- putBucket "test2" "us-east-1"
print res
res <- getLocation "test1"
print res
res <- putBucket "test1" res
fGetObject "test1" "passwd" "/tmp/passwd"
res <- deleteObject "test1" "passwd"
print res
fGetObject "test1" "passwd" "/tmp/passwd"
res <- deleteBucket "test2"
print res
print "After runResourceT"
print t

View File

@ -3,6 +3,8 @@ module Network.Minio.S3API
, getLocation
, getObject
, putBucket
, deleteBucket
, deleteObject
) where
import qualified Network.HTTP.Types as HT
@ -18,6 +20,9 @@ import Network.Minio.API
import Network.Minio.XmlParser
import Network.Minio.XmlGenerator
status204 :: HT.Status
status204 = HT.Status{ HT.statusCode = 204, HT.statusMessage = "No Content" }
getService :: Minio [BucketInfo]
getService = do
resp <- executeRequest $
@ -44,8 +49,27 @@ getObject bucket object queryParams headers = do
putBucket :: Bucket -> Location -> Minio ()
putBucket bucket location = do
resp <- executeRequest $
requestInfo HT.methodPut (Just bucket) Nothing [] [] (PayloadSingle $ mkCreateBucketConfig bucket location)
requestInfo HT.methodPut (Just bucket) Nothing [] [] $
PayloadSingle $ mkCreateBucketConfig bucket location
let httpStatus = NC.responseStatus resp
when (httpStatus /= HT.ok200) $
throwError $ MErrXml $ LBS.toStrict $ NC.responseBody resp
deleteBucket :: Bucket -> Minio ()
deleteBucket bucket = do
resp <- executeRequest $
requestInfo HT.methodDelete (Just bucket) Nothing [] [] $
(PayloadSingle "")
let httpStatus = NC.responseStatus resp
when (httpStatus /= status204) $
throwError $ MErrXml $ LBS.toStrict $ NC.responseBody resp
deleteObject :: Bucket -> Object -> Minio ()
deleteObject bucket object = do
resp <- executeRequest $
requestInfo HT.methodDelete (Just bucket) (Just object) [] [] $
(PayloadSingle "")
let httpStatus = NC.responseStatus resp
when (httpStatus /= status204) $
throwError $ MErrXml $ LBS.toStrict $ NC.responseBody resp