由于官方文档还提供了Haskell的SDK,所以我打算就一并把对应的文件操作接口封装起来。
下面是安装方法
# 在.cabal下
# 添加minio-hs
# hpack
# 在package.yml 添加 minio。hs
下面是操作代码
{-# LANGUAGE OverloadedStrings #-}
import Network.Minio
import Control.Monad.IO.Class (liftIO)
import qualified Data.Text as T
data BucketManager = BucketManager {
bmMinioConn :: MinioConn
}
createBucket :: T.Text -> Minio ()
createBucket bucketName = do
exists <- bucketExists bucketName
if exists
then liftIO $ putStrLn "该存储桶已经存在"
else do
makeBucket bucketName Nothing
liftIO $ putStrLn "存储桶创建成功"
main :: IO ()
main = do
let connInfo = ConnectInfo {
connectHost = "localhost"
, connectPort = 9000
, connectAccessKey = "minioadmin"
, connectSecretKey = "minioadmin"
, connectRegion = Nothing
, connectIsSecure = False
}
runMinio connInfo $ do
createBucket "testbucket"