Add deleteBucket and deleteObject api
This commit is contained in:
parent
45d5f9e676
commit
2cda5d2e55
10
app/Main.hs
10
app/Main.hs
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user