module Network.Minio
(
ConnectInfo(..)
, awsCI
, awsWithRegionCI
, minioPlayCI
, minioCI
, Minio
, runMinio
, def
, Bucket
, makeBucket
, removeBucket
, bucketExists
, Region
, getLocation
, BucketInfo(..)
, listBuckets
, ObjectInfo(..)
, listObjects
, listObjectsV1
, UploadId
, UploadInfo(..)
, listIncompleteUploads
, ObjectPartInfo(..)
, listIncompleteParts
, Notification(..)
, NotificationConfig(..)
, Arn
, Event(..)
, Filter(..)
, FilterKey(..)
, FilterRules(..)
, FilterRule(..)
, getBucketNotification
, putBucketNotification
, removeAllBucketNotification
, Object
, fGetObject
, fPutObject
, putObject
, getObject
, CopyPartSource(..)
, copyObject
, statObject
, removeObject
, removeIncompleteUpload
, UrlExpiry
, presignedPutObjectUrl
, presignedGetObjectUrl
, presignedHeadObjectUrl
, PostPolicy
, PostPolicyError(..)
, newPostPolicy
, presignedPostPolicy
, showPostPolicy
, PostPolicyCondition
, ppCondBucket
, ppCondContentLengthRange
, ppCondContentType
, ppCondKey
, ppCondKeyStartsWith
, ppCondSuccessActionStatus
, MinioErr(..)
, MErrV(..)
, ServiceErr(..)
) where
import qualified Data.Conduit as C
import qualified Data.Conduit.Binary as CB
import qualified Data.Conduit.Combinators as CC
import Data.Default (def)
import qualified Data.Map as Map
import Lib.Prelude
import Network.Minio.Data
import Network.Minio.Errors
import Network.Minio.ListOps
import Network.Minio.PutObject
import Network.Minio.S3API
listBuckets :: Minio [BucketInfo]
listBuckets = getService
fGetObject :: Bucket -> Object -> FilePath -> Minio ()
fGetObject bucket object fp = do
src <- getObject bucket object
src C.$$+- CB.sinkFileCautious fp
fPutObject :: Bucket -> Object -> FilePath -> Minio ()
fPutObject bucket object f = void $ putObjectInternal bucket object $
ODFile f Nothing
putObject :: Bucket -> Object -> C.Producer Minio ByteString
-> Maybe Int64 -> Minio ()
putObject bucket object src sizeMay =
void $ putObjectInternal bucket object $ ODStream src sizeMay
copyObject :: Bucket -> Object -> CopyPartSource -> Minio ()
copyObject bucket object cps = void $ copyObjectInternal bucket object cps
removeObject :: Bucket -> Object -> Minio ()
removeObject = deleteObject
getObject :: Bucket -> Object -> Minio (C.ResumableSource Minio ByteString)
getObject bucket object = snd <$> getObject' bucket object [] []
statObject :: Bucket -> Object -> Minio ObjectInfo
statObject = headObject
makeBucket :: Bucket -> Maybe Region -> Minio ()
makeBucket bucket regionMay = do
region <- maybe (asks $ connectRegion . mcConnInfo) return regionMay
putBucket bucket region
modify (Map.insert bucket region)
removeBucket :: Bucket -> Minio ()
removeBucket bucket = do
deleteBucket bucket
modify (Map.delete bucket)
bucketExists :: Bucket -> Minio Bool
bucketExists = headBucket
removeIncompleteUpload :: Bucket -> Object -> Minio ()
removeIncompleteUpload bucket object = do
uploads <- listIncompleteUploads bucket (Just object) False C.$$ CC.sinkList
mapM_ (abortMultipartUpload bucket object) (uiUploadId <$> uploads)