diff --git a/README.md b/README.md
index 5be1587..f198ad2 100644
--- a/README.md
+++ b/README.md
@@ -44,18 +44,36 @@ stack haddock
### FileUploader.hs
``` haskell
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs --package optparse-applicative --package filepath
+-- stack --resolver lts-11.1 runghc --package minio-hs --package optparse-applicative --package filepath
-{-# Language OverloadedStrings, ScopedTypeVariables #-}
-import Network.Minio
+--
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
-import Control.Monad.Catch (catchIf)
-import Control.Monad.IO.Class (liftIO)
-import Data.Monoid ((<>))
-import Data.Text (pack)
-import Options.Applicative
-import Prelude
-import System.FilePath.Posix
+
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+import Network.Minio
+
+import Data.Monoid ((<>))
+import Data.Text (pack)
+import Options.Applicative
+import System.FilePath.Posix
+import UnliftIO (throwIO, try)
+
+import Prelude
-- | The following example uses minio's play server at
-- https://play.minio.io:9000. The endpoint and associated
@@ -77,27 +95,27 @@ cmdParser = info
<> header
"FileUploader - a simple file-uploader program using minio-hs")
-ignoreMinioErr :: ServiceErr -> Minio ()
-ignoreMinioErr = return . const ()
-
-
main :: IO ()
main = do
let bucket = "my-bucket"
- -- Parse command line argument, namely --filename.
+ -- Parse command line argument
filepath <- execParser cmdParser
let object = pack $ takeBaseName filepath
res <- runMinio minioPlayCI $ do
-- Make a bucket; catch bucket already exists exception if thrown.
- catchIf (== BucketAlreadyOwnedByYou) (makeBucket bucket Nothing) ignoreMinioErr
+ bErr <- try $ makeBucket bucket Nothing
+ case bErr of
+ Left (MErrService BucketAlreadyOwnedByYou) -> return ()
+ Left e -> throwIO e
+ Right _ -> return ()
-- Upload filepath to bucket; object is derived from filepath.
- fPutObject bucket object filepath
+ fPutObject bucket object filepath def
case res of
- Left e -> putStrLn $ "file upload failed due to " ++ (show e)
+ Left e -> putStrLn $ "file upload failed due to " ++ (show e)
Right () -> putStrLn "file upload succeeded."
```
diff --git a/docs/API.md b/docs/API.md
index d703bdd..ce9affe 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -185,7 +185,6 @@ main :: IO ()
main = do
res <- runMinio minioPlayCI $ do
makeBucket bucketName (Just "us-east-1")
-
case res of
Left err -> putStrLn $ "Failed to make bucket: " ++ (show res)
Right _ -> putStrLn $ "makeBucket successful."
@@ -225,7 +224,7 @@ main = do
-### listObjects :: Bucket -> Maybe Text -> Bool -> C.Producer Minio ObjectInfo
+### listObjects :: Bucket -> Maybe Text -> Bool -> C.ConduitM () ObjectInfo Minio ()
List objects in the given bucket, implements version 2 of AWS S3 API.
@@ -244,7 +243,7 @@ __Return Value__
|Return type |Description |
|:---|:---|
-| _C.Producer Minio ObjectInfo_ | A Conduit Producer of `ObjectInfo` values corresponding to each object. |
+| _C.ConduitM () ObjectInfo Minio ()_ | A Conduit Producer of `ObjectInfo` values corresponding to each object. |
__ObjectInfo record type__
@@ -258,10 +257,19 @@ __ObjectInfo record type__
__Example__
``` haskell
-{-# Language OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings #-}
+import Network.Minio
-import Data.Conduit (($$))
-import Conduit.Combinators (sinkList)
+import Conduit
+import Prelude
+
+
+-- | The following example uses minio's play server at
+-- https://play.minio.io:9000. The endpoint and associated
+-- credentials are provided via the libary constant,
+--
+-- > minioPlayCI :: ConnectInfo
+--
main :: IO ()
main = do
@@ -270,14 +278,13 @@ main = do
-- Performs a recursive listing of all objects under bucket "test"
-- on play.minio.io.
- res <- runMinio minioPlayCI $ do
- listObjects bucket Nothing True $$ sinkList
+ res <- runMinio minioPlayCI $
+ runConduit $ listObjects bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
print res
-
```
-### listObjectsV1 :: Bucket -> Maybe Text -> Bool -> C.Producer Minio ObjectInfo
+### listObjectsV1 :: Bucket -> Maybe Text -> Bool -> C.ConduitM () ObjectInfo Minio ()
List objects in the given bucket, implements version 1 of AWS S3 API. This API
is provided for legacy S3 compatible object storage endpoints.
@@ -297,7 +304,7 @@ __Return Value__
|Return type |Description |
|:---|:---|
-| _C.Producer Minio ObjectInfo_ | A Conduit Producer of `ObjectInfo` values corresponding to each object. |
+| _C.ConduitM () ObjectInfo Minio ()_ | A Conduit Producer of `ObjectInfo` values corresponding to each object. |
__ObjectInfo record type__
@@ -311,10 +318,19 @@ __ObjectInfo record type__
__Example__
``` haskell
-{-# Language OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings #-}
+import Network.Minio
-import Data.Conduit (($$))
-import Conduit.Combinators (sinkList)
+import Conduit
+import Prelude
+
+
+-- | The following example uses minio's play server at
+-- https://play.minio.io:9000. The endpoint and associated
+-- credentials are provided via the libary constant,
+--
+-- > minioPlayCI :: ConnectInfo
+--
main :: IO ()
main = do
@@ -323,10 +339,9 @@ main = do
-- Performs a recursive listing of all objects under bucket "test"
-- on play.minio.io.
- res <- runMinio minioPlayCI $ do
- listObjectsV1 bucket Nothing True $$ sinkList
+ res <- runMinio minioPlayCI $
+ runConduit $ listObjectsV1 bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
print res
-
```
@@ -349,7 +364,7 @@ __Return Value__
|Return type |Description |
|:---|:---|
-| _C.Producer Minio UploadInfo_ | A Conduit Producer of `UploadInfo` values corresponding to each incomplete multipart upload |
+| _C.ConduitM () UploadInfo Minio ()_ | A Conduit Producer of `UploadInfo` values corresponding to each incomplete multipart upload |
__UploadInfo record type__
@@ -362,20 +377,28 @@ __UploadInfo record type__
__Example__
```haskell
-{-# Language OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings #-}
+import Network.Minio
-import Data.Conduit (($$))
-import Conduit.Combinators (sinkList)
+import Conduit
+import Prelude
+
+-- | The following example uses minio's play server at
+-- https://play.minio.io:9000. The endpoint and associated
+-- credentials are provided via the libary constant,
+--
+-- > minioPlayCI :: ConnectInfo
+--
main :: IO ()
main = do
let
bucket = "test"
- -- Performs a recursive listing of all incompletely uploaded objects
- -- under bucket "test" on play.minio.io.
- res <- runMinio minioPlayCI $ do
- listIncompleteUploads bucket Nothing True $$ sinkList
+ -- Performs a recursive listing of incomplete uploads under bucket "test"
+ -- on a local minio server.
+ res <- runMinio minioPlayCI $
+ runConduit $ listIncompleteUploads bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
print res
```
@@ -383,19 +406,30 @@ main = do
## 3. Object operations
-### getObject :: Bucket -> Object -> Minio (C.ResumableSource Minio ByteString)
+### getObject :: Bucket -> Object -> GetObjectOptions -> Minio (C.ConduitM () ByteString Minio ())
-Get an object from the service.
+Get an object from the S3 service, optionally object ranges can be provided as well.
__Parameters__
-In the expression `getObject bucketName objectName` the parameters
+In the expression `getObject bucketName objectName opts` the parameters
are:
|Param |Type |Description |
|:---|:---| :---|
| `bucketName` | _Bucket_ (alias for `Text`) | Name of the bucket |
| `objectName` | _Object_ (alias for `Text`) | Name of the object |
+| `opts` | _GetObjectOptions_ | Options for GET requests specifying additional options like If-Match, Range |
+
+__GetObjectOptions record type__
+
+|Field |Type |Description |
+|:---|:---| :---|
+| `gooRange` | `Maybe ByteRanges` | Represents the byte range of object. E.g ByteRangeFromTo 0 9 represents first ten bytes of the object|
+| `gooIfMatch` | `Maybe ETag` (alias for `Text`) | (Optional) ETag of object should match |
+| `gooIfNoneMatch` | `Maybe ETag` (alias for `Text`) | (Optional) ETag of object shouldn't match |
+| `gooIfUnmodifiedSince` | `Maybe UTCTime` | (Optional) Time since object wasn't modified |
+| `gooIfModifiedSince` | `Maybe UTCTime` | (Optional) Time since object was modified |
__Return Value__
@@ -403,41 +437,45 @@ The return value can be incrementally read to process the contents of
the object.
|Return type |Description |
|:---|:---|
-| _C.ResumableSource Minio ByteString_ | A Conduit ResumableSource of `ByteString` values. |
+| _Minio (C.ConduitM () ByteString Minio ())_ | A Conduit source of `ByteString` values. |
__Example__
```haskell
-{-# Language OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings #-}
+import Network.Minio
-import Network.Minio
-import Data.Conduit (($$+-))
-import Data.Conduit.Binary (sinkLbs)
-import qualified Data.ByteString.Lazy as LB
+import qualified Data.Conduit as C
+import qualified Data.Conduit.Binary as CB
+
+import Prelude
+
+-- | The following example uses minio's play server at
+-- https://play.minio.io:9000. The endpoint and associated
+-- credentials are provided via the libary constant,
+--
+-- > minioPlayCI :: ConnectInfo
+--
main :: IO ()
main = do
let
- bucket = "mybucket"
- object = "myobject"
-
- -- Lists the parts in an incompletely uploaded object identified by
- -- bucket, object and upload ID.
+ bucket = "my-bucket"
+ object = "my-object"
res <- runMinio minioPlayCI $ do
- source <- getObject bucket object
- source $$+- sinkLbs
+ src <- getObject bucket object def
+ C.connect src $ CB.sinkFileCautious "/tmp/my-object"
- -- the following the prints the contents of the object.
- putStrLn $ either
- (("Failed to getObject: " ++) . show)
- (("Read an object of length: " ++) . show . LB.length)
- res
+ case res of
+ Left e -> putStrLn $ "getObject failed." ++ (show e)
+ Right _ -> putStrLn "getObject succeeded."
```
-### putObject :: Bucket -> Object -> C.Producer Minio ByteString -> Maybe Int64 -> Minio ()
+### putObject :: Bucket -> Object -> C.ConduitM () ByteString Minio () -> Maybe Int64 -> PutObjectOptions -> Minio ()
Uploads an object to a bucket in the service, from the given input
-byte stream of optionally supplied length
+byte stream of optionally supplied length. Optionally you can also specify
+additional metadata for the object.
__Parameters__
@@ -448,28 +486,42 @@ are:
|:---|:---| :---|
| `bucketName` | _Bucket_ (alias for `Text`) | Name of the bucket |
| `objectName` | _Object_ (alias for `Text`) | Name of the object |
-| `inputSrc` | _C.Producer Minio ByteString_ | A Conduit Producer of `ByteString` values |
+| `inputSrc` | _C.ConduitM () ByteString Minio ()_ | A Conduit producer of `ByteString` values |
+| `size` | _Int64_ | Provide stream size (optional) |
+| `opts` | _PutObjectOptions_ | Optional parameters to provide additional metadata for the object |
__Example__
```haskell
-{-# Language OverloadedStrings #-}
-import Network.Minio
+{-# LANGUAGE OverloadedStrings #-}
+import Network.Minio
+
import qualified Data.Conduit.Combinators as CC
+import Prelude
+
+-- | The following example uses minio's play server at
+-- https://play.minio.io:9000. The endpoint and associated
+-- credentials are provided via the libary constant,
+--
+-- > minioPlayCI :: ConnectInfo
+--
+
main :: IO ()
main = do
let
- bucket = "mybucket"
- object = "myobject"
- kb15 = 15 * 1024
-
- res <- runMinio minioPlayCI $ do
- putObject bucket object (CC.repeat "a") (Just kb15)
+ bucket = "test"
+ object = "obj"
+ localFile = "/etc/lsb-release"
+ kb15 = 15 * 1024
+ -- Eg 1. Upload a stream of repeating "a" using putObject with default options.
+ res <- runMinio minioPlayCI $
+ putObject bucket object (CC.repeat "a") (Just kb15) def
case res of
- Left e -> putStrLn $ "Failed to putObject " ++ show bucket ++ "/" ++ show object
- Right _ -> putStrLn "PutObject was successful"
+ Left e -> putStrLn $ "putObject failed." ++ show e
+ Right () -> putStrLn "putObject succeeded."
+
```
diff --git a/examples/BucketExists.hs b/examples/BucketExists.hs
index db6d326..fa99ea5 100755
--- a/examples/BucketExists.hs
+++ b/examples/BucketExists.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/CopyObject.hs b/examples/CopyObject.hs
index 6665658..d43dae7 100755
--- a/examples/CopyObject.hs
+++ b/examples/CopyObject.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/FileUploader.hs b/examples/FileUploader.hs
index a518b29..45fb1e3 100755
--- a/examples/FileUploader.hs
+++ b/examples/FileUploader.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs --package optparse-applicative --package filepath
+-- stack --resolver lts-11.1 runghc --package minio-hs --package optparse-applicative --package filepath
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
@@ -22,13 +22,13 @@
{-# LANGUAGE ScopedTypeVariables #-}
import Network.Minio
-import Control.Monad.Catch (catchIf)
-import Control.Monad.IO.Class (liftIO)
-import Data.Monoid ((<>))
-import Data.Text (pack)
+import Data.Monoid ((<>))
+import Data.Text (pack)
import Options.Applicative
-import Prelude
import System.FilePath.Posix
+import UnliftIO (throwIO, try)
+
+import Prelude
-- | The following example uses minio's play server at
-- https://play.minio.io:9000. The endpoint and associated
@@ -50,10 +50,6 @@ cmdParser = info
<> header
"FileUploader - a simple file-uploader program using minio-hs")
-ignoreMinioErr :: ServiceErr -> Minio ()
-ignoreMinioErr = return . const ()
-
-
main :: IO ()
main = do
let bucket = "my-bucket"
@@ -64,10 +60,14 @@ main = do
res <- runMinio minioPlayCI $ do
-- Make a bucket; catch bucket already exists exception if thrown.
- catchIf (== BucketAlreadyOwnedByYou) (makeBucket bucket Nothing) ignoreMinioErr
+ bErr <- try $ makeBucket bucket Nothing
+ case bErr of
+ Left (MErrService BucketAlreadyOwnedByYou) -> return ()
+ Left e -> throwIO e
+ Right _ -> return ()
-- Upload filepath to bucket; object is derived from filepath.
- fPutObject bucket object filepath
+ fPutObject bucket object filepath def
case res of
Left e -> putStrLn $ "file upload failed due to " ++ (show e)
diff --git a/examples/GetConfig.hs b/examples/GetConfig.hs
index cbff561..0022dbe 100755
--- a/examples/GetConfig.hs
+++ b/examples/GetConfig.hs
@@ -2,7 +2,7 @@
-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2018 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/GetObject.hs b/examples/GetObject.hs
index b4ead1a..6664ce6 100755
--- a/examples/GetObject.hs
+++ b/examples/GetObject.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
@@ -20,8 +20,9 @@
{-# LANGUAGE OverloadedStrings #-}
import Network.Minio
-import Data.Conduit (($$+-))
-import Data.Conduit.Binary (sinkLbs)
+import qualified Data.Conduit as C
+import qualified Data.Conduit.Binary as CB
+
import Prelude
-- | The following example uses minio's play server at
@@ -37,8 +38,8 @@ main = do
bucket = "my-bucket"
object = "my-object"
res <- runMinio minioPlayCI $ do
- src <- getObject bucket object
- (src $$+- sinkLbs)
+ src <- getObject bucket object def
+ C.connect src $ CB.sinkFileCautious "/tmp/my-object"
case res of
Left e -> putStrLn $ "getObject failed." ++ (show e)
diff --git a/examples/HeadObject.hs b/examples/HeadObject.hs
index 851a50a..162f69f 100755
--- a/examples/HeadObject.hs
+++ b/examples/HeadObject.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/Heal.hs b/examples/Heal.hs
index 8e4ef8c..9b15897 100755
--- a/examples/Heal.hs
+++ b/examples/Heal.hs
@@ -2,7 +2,7 @@
-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2018 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/ListBuckets.hs b/examples/ListBuckets.hs
index 549bb17..8b54b7f 100755
--- a/examples/ListBuckets.hs
+++ b/examples/ListBuckets.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/ListIncompleteUploads.hs b/examples/ListIncompleteUploads.hs
index 054d101..4bbd5c9 100755
--- a/examples/ListIncompleteUploads.hs
+++ b/examples/ListIncompleteUploads.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
@@ -20,8 +20,7 @@
{-# LANGUAGE OverloadedStrings #-}
import Network.Minio
-import Data.Conduit (($$))
-import Data.Conduit.Combinators (sinkList)
+import Conduit
import Prelude
-- | The following example uses minio's play server at
@@ -39,7 +38,7 @@ main = do
-- Performs a recursive listing of incomplete uploads under bucket "test"
-- on a local minio server.
res <- runMinio minioPlayCI $
- listIncompleteUploads bucket Nothing True $$ sinkList
+ runConduit $ listIncompleteUploads bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
print res
{-
diff --git a/examples/ListObjects.hs b/examples/ListObjects.hs
index c76d695..3a80986 100755
--- a/examples/ListObjects.hs
+++ b/examples/ListObjects.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
@@ -20,8 +20,7 @@
{-# LANGUAGE OverloadedStrings #-}
import Network.Minio
-import qualified Data.Conduit as C
-import qualified Data.Conduit.Combinators as CC
+import Conduit
import Prelude
@@ -40,9 +39,8 @@ main = do
-- Performs a recursive listing of all objects under bucket "test"
-- on play.minio.io.
res <- runMinio minioPlayCI $
- listObjects bucket Nothing True C.$$ CC.sinkList
+ runConduit $ listObjects bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
print res
-
{-
Following is the output of the above program on a local Minio server.
diff --git a/examples/Makebucket.hs b/examples/MakeBucket.hs
similarity index 88%
rename from examples/Makebucket.hs
rename to examples/MakeBucket.hs
index 83d09fd..05c1ce6 100755
--- a/examples/Makebucket.hs
+++ b/examples/MakeBucket.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
@@ -32,8 +32,7 @@ import Prelude
main :: IO ()
main = do
- let
- bucket = "my-bucket"
+ let bucket = "my-bucket"
res <- runMinio minioPlayCI $
-- N B the region provided for makeBucket is optional.
makeBucket bucket (Just "us-east-1")
diff --git a/examples/PresignedGetObject.hs b/examples/PresignedGetObject.hs
index 0850865..107c822 100755
--- a/examples/PresignedGetObject.hs
+++ b/examples/PresignedGetObject.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/PresignedPostPolicy.hs b/examples/PresignedPostPolicy.hs
index 1d4a4c8..73ae6a4 100755
--- a/examples/PresignedPostPolicy.hs
+++ b/examples/PresignedPostPolicy.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/PresignedPutObject.hs b/examples/PresignedPutObject.hs
index f6f0b12..fcf5577 100755
--- a/examples/PresignedPutObject.hs
+++ b/examples/PresignedPutObject.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/PutObject.hs b/examples/PutObject.hs
index 1a94ab7..fc7bee3 100755
--- a/examples/PutObject.hs
+++ b/examples/PutObject.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@ import Network.Minio
import qualified Data.Conduit.Combinators as CC
+import Prelude
+
-- | The following example uses minio's play server at
-- https://play.minio.io:9000. The endpoint and associated
-- credentials are provided via the libary constant,
@@ -44,7 +46,6 @@ main = do
Left e -> putStrLn $ "putObject failed." ++ show e
Right () -> putStrLn "putObject succeeded."
-
-- Eg 2. Upload a file using fPutObject with default options.
res2 <- runMinio minioPlayCI $
fPutObject bucket object localFile def
diff --git a/examples/Removebucket.hs b/examples/RemoveBucket.hs
similarity index 90%
rename from examples/Removebucket.hs
rename to examples/RemoveBucket.hs
index 6b219f3..a61645e 100755
--- a/examples/Removebucket.hs
+++ b/examples/RemoveBucket.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/RemoveIncompleteUpload.hs b/examples/RemoveIncompleteUpload.hs
index cf1999f..319dbd6 100755
--- a/examples/RemoveIncompleteUpload.hs
+++ b/examples/RemoveIncompleteUpload.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/RemoveObject.hs b/examples/RemoveObject.hs
index e901c51..c6346b6 100755
--- a/examples/RemoveObject.hs
+++ b/examples/RemoveObject.hs
@@ -1,8 +1,8 @@
#!/usr/bin/env stack
--- stack --resolver lts-9.1 runghc --package minio-hs
+-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2017 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/ServerInfo.hs b/examples/ServerInfo.hs
index 8f27a15..f69151c 100755
--- a/examples/ServerInfo.hs
+++ b/examples/ServerInfo.hs
@@ -2,7 +2,7 @@
-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2018 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/examples/SetConfig.hs b/examples/SetConfig.hs
index 7c2e152..80d256c 100755
--- a/examples/SetConfig.hs
+++ b/examples/SetConfig.hs
@@ -2,7 +2,7 @@
-- stack --resolver lts-11.1 runghc --package minio-hs
--
--- Minio Haskell SDK, (C) 2018 Minio, Inc.
+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
diff --git a/src/Network/Minio/JsonParser.hs b/src/Network/Minio/JsonParser.hs
index cc6c4e2..ee3452b 100644
--- a/src/Network/Minio/JsonParser.hs
+++ b/src/Network/Minio/JsonParser.hs
@@ -38,5 +38,5 @@ instance FromJSON AdminErrJSON where
parseErrResponseJSON :: (MonadIO m) => LByteString -> m ServiceErr
parseErrResponseJSON jsondata =
case eitherDecode jsondata of
- Right (AdminErrJSON code message) -> return $ toServiceErr code message
- Left err -> throwIO $ MErrVJsonParse $ T.pack err
+ Right aErr -> return $ toServiceErr (aeCode aErr) (aeMessage aErr)
+ Left err -> throwIO $ MErrVJsonParse $ T.pack err
diff --git a/src/Network/Minio/PutObject.hs b/src/Network/Minio/PutObject.hs
index 5c36a78..f4bb5b4 100644
--- a/src/Network/Minio/PutObject.hs
+++ b/src/Network/Minio/PutObject.hs
@@ -22,6 +22,7 @@ module Network.Minio.PutObject
) where
+import Conduit (takeC)
import qualified Data.ByteString.Lazy as LBS
import qualified Data.Conduit as C
import qualified Data.Conduit.Binary as CB
@@ -68,7 +69,7 @@ putObjectInternal b o opts (ODStream src sizeMay) = do
-- got file size, so check for single/multipart upload
Just size ->
if | size <= 64 * oneMiB -> do
- bs <- C.runConduit $ src C..| CB.sinkLbs
+ bs <- C.runConduit $ src C..| takeC (fromIntegral size) C..| CB.sinkLbs
putObjectSingle' b o (pooToHeaders opts) $ LBS.toStrict bs
| size > maxObjectSize -> throwIO $ MErrVPutSizeExceeded size
| otherwise -> sequentialMultipartUpload b o opts (Just size) src