git.iko.soy/typeable/minio-hs
on master help sign in
Fix examples to point to lts-11.1 and update docs (#98)
commit22808fcdaf25a9fd39da5bd80de64f8890bbea69 authorHarshavardhana <harsha@minio.io> dateFri 8 Jun 2018, 15:44 (8 years ago) parent7564cbd
24 files changed+210−141
README.md+36−18 docs/API.md+111−59 examples/BucketExists.hs+2−2 examples/CopyObject.hs+2−2 examples/FileUploader.hs+13−13 examples/GetConfig.hs+1−1 examples/GetObject.hs+7−6 examples/HeadObject.hs+2−2 examples/Heal.hs+1−1 examples/ListBuckets.hs+2−2 examples/ListIncompleteUploads.hs+4−5 examples/ListObjects.hs+4−6 examples/Makebucket.hs → examples/MakeBucket.hs+3−4 examples/PresignedGetObject.hs+2−2 examples/PresignedPostPolicy.hs+2−2 examples/PresignedPutObject.hs+2−2 examples/PutObject.hs+4−3 examples/Removebucket.hs → examples/RemoveBucket.hs+2−2 examples/RemoveIncompleteUpload.hs+2−2 examples/RemoveObject.hs+2−2 examples/ServerInfo.hs+1−1 examples/SetConfig.hs+1−1 src/Network/Minio/JsonParser.hs+2−2 src/Network/Minio/PutObject.hs+2−1
README.md+36−18
@@ -44,18 +44,36 @@ stack haddock
4444### FileUploader.hs
4545``` haskell
4646#!/usr/bin/env stack
47−-- stack --resolver lts-9.1 runghc --package minio-hs --package optparse-applicative --package filepath
47+-- stack --resolver lts-11.1 runghc --package minio-hs --package optparse-applicative --package filepath
4848
49−{-# Language OverloadedStrings, ScopedTypeVariables #-}
50−import Network.Minio
49+--
50+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
51+--
52+-- Licensed under the Apache License, Version 2.0 (the "License");
53+-- you may not use this file except in compliance with the License.
54+-- You may obtain a copy of the License at
55+--
56+-- http://www.apache.org/licenses/LICENSE-2.0
57+--
58+-- Unless required by applicable law or agreed to in writing, software
59+-- distributed under the License is distributed on an "AS IS" BASIS,
60+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61+-- See the License for the specific language governing permissions and
62+-- limitations under the License.
63+--
5164
52−import Control.Monad.Catch (catchIf)
53−import Control.Monad.IO.Class (liftIO)
54−import Data.Monoid ((<>))
55−import Data.Text (pack)
56−import Options.Applicative
57−import Prelude
58−import System.FilePath.Posix
65+
66+{-# LANGUAGE OverloadedStrings #-}
67+{-# LANGUAGE ScopedTypeVariables #-}
68+import Network.Minio
69+
70+import Data.Monoid ((<>))
71+import Data.Text (pack)
72+import Options.Applicative
73+import System.FilePath.Posix
74+import UnliftIO (throwIO, try)
75+
76+import Prelude
5977
6078-- | The following example uses minio's play server at
6179-- https://play.minio.io:9000. The endpoint and associated
@@ -77,27 +95,27 @@ cmdParser = info
7795 <> header
7896 "FileUploader - a simple file-uploader program using minio-hs")
7997
80−ignoreMinioErr :: ServiceErr -> Minio ()
81−ignoreMinioErr = return . const ()
82−
83−
8498main :: IO ()
8599main = do
86100 let bucket = "my-bucket"
87101
88− -- Parse command line argument, namely --filename.
102+ -- Parse command line argument
89103 filepath <- execParser cmdParser
90104 let object = pack $ takeBaseName filepath
91105
92106 res <- runMinio minioPlayCI $ do
93107 -- Make a bucket; catch bucket already exists exception if thrown.
94− catchIf (== BucketAlreadyOwnedByYou) (makeBucket bucket Nothing) ignoreMinioErr
108+ bErr <- try $ makeBucket bucket Nothing
109+ case bErr of
110+ Left (MErrService BucketAlreadyOwnedByYou) -> return ()
111+ Left e -> throwIO e
112+ Right _ -> return ()
95113
96114 -- Upload filepath to bucket; object is derived from filepath.
97− fPutObject bucket object filepath
115+ fPutObject bucket object filepath def
98116
99117 case res of
100− Left e -> putStrLn $ "file upload failed due to " ++ (show e)
118+ Left e -> putStrLn $ "file upload failed due to " ++ (show e)
101119 Right () -> putStrLn "file upload succeeded."
102120```
103121
docs/API.md+111−59
@@ -185,7 +185,6 @@ main :: IO ()
185185main = do
186186 res <- runMinio minioPlayCI $ do
187187 makeBucket bucketName (Just "us-east-1")
188−
189188 case res of
190189 Left err -> putStrLn $ "Failed to make bucket: " ++ (show res)
191190 Right _ -> putStrLn $ "makeBucket successful."
@@ -225,7 +224,7 @@ main = do
225224
226225
227226<a name="listObjects"></a>
228−### listObjects :: Bucket -> Maybe Text -> Bool -> C.Producer Minio ObjectInfo
227+### listObjects :: Bucket -> Maybe Text -> Bool -> C.ConduitM () ObjectInfo Minio ()
229228
230229List objects in the given bucket, implements version 2 of AWS S3 API.
231230
@@ -244,7 +243,7 @@ __Return Value__
244243
245244|Return type |Description |
246245|:---|:---|
247−| _C.Producer Minio ObjectInfo_ | A Conduit Producer of `ObjectInfo` values corresponding to each object. |
246+| _C.ConduitM () ObjectInfo Minio ()_ | A Conduit Producer of `ObjectInfo` values corresponding to each object. |
248247
249248__ObjectInfo record type__
250249
@@ -258,10 +257,19 @@ __ObjectInfo record type__
258257__Example__
259258
260259``` haskell
261−{-# Language OverloadedStrings #-}
260+{-# LANGUAGE OverloadedStrings #-}
261+import Network.Minio
262+
263+import Conduit
264+import Prelude
262265
263−import Data.Conduit (($$))
264−import Conduit.Combinators (sinkList)
266+
267+-- | The following example uses minio's play server at
268+-- https://play.minio.io:9000. The endpoint and associated
269+-- credentials are provided via the libary constant,
270+--
271+-- > minioPlayCI :: ConnectInfo
272+--
265273
266274main :: IO ()
267275main = do
@@ -270,14 +278,13 @@ main = do
270278
271279 -- Performs a recursive listing of all objects under bucket "test"
272280 -- on play.minio.io.
273− res <- runMinio minioPlayCI $ do
274− listObjects bucket Nothing True $$ sinkList
281+ res <- runMinio minioPlayCI $
282+ runConduit $ listObjects bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
275283 print res
276−
277284```
278285
279286<a name="listObjectsV1"></a>
280−### listObjectsV1 :: Bucket -> Maybe Text -> Bool -> C.Producer Minio ObjectInfo
287+### listObjectsV1 :: Bucket -> Maybe Text -> Bool -> C.ConduitM () ObjectInfo Minio ()
281288
282289List objects in the given bucket, implements version 1 of AWS S3 API. This API
283290is provided for legacy S3 compatible object storage endpoints.
@@ -297,7 +304,7 @@ __Return Value__
297304
298305|Return type |Description |
299306|:---|:---|
300−| _C.Producer Minio ObjectInfo_ | A Conduit Producer of `ObjectInfo` values corresponding to each object. |
307+| _C.ConduitM () ObjectInfo Minio ()_ | A Conduit Producer of `ObjectInfo` values corresponding to each object. |
301308
302309__ObjectInfo record type__
303310
@@ -311,10 +318,19 @@ __ObjectInfo record type__
311318__Example__
312319
313320``` haskell
314−{-# Language OverloadedStrings #-}
321+{-# LANGUAGE OverloadedStrings #-}
322+import Network.Minio
323+
324+import Conduit
325+import Prelude
326+
315327
316−import Data.Conduit (($$))
317−import Conduit.Combinators (sinkList)
328+-- | The following example uses minio's play server at
329+-- https://play.minio.io:9000. The endpoint and associated
330+-- credentials are provided via the libary constant,
331+--
332+-- > minioPlayCI :: ConnectInfo
333+--
318334
319335main :: IO ()
320336main = do
@@ -323,10 +339,9 @@ main = do
323339
324340 -- Performs a recursive listing of all objects under bucket "test"
325341 -- on play.minio.io.
326− res <- runMinio minioPlayCI $ do
327− listObjectsV1 bucket Nothing True $$ sinkList
342+ res <- runMinio minioPlayCI $
343+ runConduit $ listObjectsV1 bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
328344 print res
329−
330345```
331346
332347<a name="listIncompleteUploads"></a>
@@ -349,7 +364,7 @@ __Return Value__
349364
350365|Return type |Description |
351366|:---|:---|
352−| _C.Producer Minio UploadInfo_ | A Conduit Producer of `UploadInfo` values corresponding to each incomplete multipart upload |
367+| _C.ConduitM () UploadInfo Minio ()_ | A Conduit Producer of `UploadInfo` values corresponding to each incomplete multipart upload |
353368
354369__UploadInfo record type__
355370
@@ -362,20 +377,28 @@ __UploadInfo record type__
362377__Example__
363378
364379```haskell
365−{-# Language OverloadedStrings #-}
380+{-# LANGUAGE OverloadedStrings #-}
381+import Network.Minio
366382
367−import Data.Conduit (($$))
368−import Conduit.Combinators (sinkList)
383+import Conduit
384+import Prelude
385+
386+-- | The following example uses minio's play server at
387+-- https://play.minio.io:9000. The endpoint and associated
388+-- credentials are provided via the libary constant,
389+--
390+-- > minioPlayCI :: ConnectInfo
391+--
369392
370393main :: IO ()
371394main = do
372395 let
373396 bucket = "test"
374397
375− -- Performs a recursive listing of all incompletely uploaded objects
376− -- under bucket "test" on play.minio.io.
377− res <- runMinio minioPlayCI $ do
378− listIncompleteUploads bucket Nothing True $$ sinkList
398+ -- Performs a recursive listing of incomplete uploads under bucket "test"
399+ -- on a local minio server.
400+ res <- runMinio minioPlayCI $
401+ runConduit $ listIncompleteUploads bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
379402 print res
380403
381404```
@@ -383,19 +406,30 @@ main = do
383406## 3. Object operations
384407
385408<a name="getObject"></a>
386−### getObject :: Bucket -> Object -> Minio (C.ResumableSource Minio ByteString)
409+### getObject :: Bucket -> Object -> GetObjectOptions -> Minio (C.ConduitM () ByteString Minio ())
387410
388−Get an object from the service.
411+Get an object from the S3 service, optionally object ranges can be provided as well.
389412
390413__Parameters__
391414
392−In the expression `getObject bucketName objectName` the parameters
415+In the expression `getObject bucketName objectName opts` the parameters
393416are:
394417
395418|Param |Type |Description |
396419|:---|:---| :---|
397420| `bucketName` | _Bucket_ (alias for `Text`) | Name of the bucket |
398421| `objectName` | _Object_ (alias for `Text`) | Name of the object |
422+| `opts` | _GetObjectOptions_ | Options for GET requests specifying additional options like If-Match, Range |
423+
424+__GetObjectOptions record type__
425+
426+|Field |Type |Description |
427+|:---|:---| :---|
428+| `gooRange` | `Maybe ByteRanges` | Represents the byte range of object. E.g ByteRangeFromTo 0 9 represents first ten bytes of the object|
429+| `gooIfMatch` | `Maybe ETag` (alias for `Text`) | (Optional) ETag of object should match |
430+| `gooIfNoneMatch` | `Maybe ETag` (alias for `Text`) | (Optional) ETag of object shouldn't match |
431+| `gooIfUnmodifiedSince` | `Maybe UTCTime` | (Optional) Time since object wasn't modified |
432+| `gooIfModifiedSince` | `Maybe UTCTime` | (Optional) Time since object was modified |
399433
400434__Return Value__
401435
@@ -403,41 +437,45 @@ The return value can be incrementally read to process the contents of
403437the object.
404438|Return type |Description |
405439|:---|:---|
406−| _C.ResumableSource Minio ByteString_ | A Conduit ResumableSource of `ByteString` values. |
440+| _Minio (C.ConduitM () ByteString Minio ())_ | A Conduit source of `ByteString` values. |
407441
408442__Example__
409443
410444```haskell
411−{-# Language OverloadedStrings #-}
445+{-# LANGUAGE OverloadedStrings #-}
446+import Network.Minio
412447
413−import Network.Minio
414−import Data.Conduit (($$+-))
415−import Data.Conduit.Binary (sinkLbs)
416−import qualified Data.ByteString.Lazy as LB
448+import qualified Data.Conduit as C
449+import qualified Data.Conduit.Binary as CB
450+
451+import Prelude
452+
453+-- | The following example uses minio's play server at
454+-- https://play.minio.io:9000. The endpoint and associated
455+-- credentials are provided via the libary constant,
456+--
457+-- > minioPlayCI :: ConnectInfo
458+--
417459
418460main :: IO ()
419461main = do
420462 let
421− bucket = "mybucket"
422− object = "myobject"
423−
424− -- Lists the parts in an incompletely uploaded object identified by
425− -- bucket, object and upload ID.
463+ bucket = "my-bucket"
464+ object = "my-object"
426465 res <- runMinio minioPlayCI $ do
427− source <- getObject bucket object
428− source $$+- sinkLbs
466+ src <- getObject bucket object def
467+ C.connect src $ CB.sinkFileCautious "/tmp/my-object"
429468
430− -- the following the prints the contents of the object.
431− putStrLn $ either
432− (("Failed to getObject: " ++) . show)
433− (("Read an object of length: " ++) . show . LB.length)
434− res
469+ case res of
470+ Left e -> putStrLn $ "getObject failed." ++ (show e)
471+ Right _ -> putStrLn "getObject succeeded."
435472```
436473
437474<a name="putObject"></a>
438−### putObject :: Bucket -> Object -> C.Producer Minio ByteString -> Maybe Int64 -> Minio ()
475+### putObject :: Bucket -> Object -> C.ConduitM () ByteString Minio () -> Maybe Int64 -> PutObjectOptions -> Minio ()
439476Uploads an object to a bucket in the service, from the given input
440−byte stream of optionally supplied length
477+byte stream of optionally supplied length. Optionally you can also specify
478+additional metadata for the object.
441479
442480__Parameters__
443481
@@ -448,28 +486,42 @@ are:
448486|:---|:---| :---|
449487| `bucketName` | _Bucket_ (alias for `Text`) | Name of the bucket |
450488| `objectName` | _Object_ (alias for `Text`) | Name of the object |
451−| `inputSrc` | _C.Producer Minio ByteString_ | A Conduit Producer of `ByteString` values |
489+| `inputSrc` | _C.ConduitM () ByteString Minio ()_ | A Conduit producer of `ByteString` values |
490+| `size` | _Int64_ | Provide stream size (optional) |
491+| `opts` | _PutObjectOptions_ | Optional parameters to provide additional metadata for the object |
452492
453493__Example__
454494
455495```haskell
456−{-# Language OverloadedStrings #-}
457−import Network.Minio
496+{-# LANGUAGE OverloadedStrings #-}
497+import Network.Minio
498+
458499import qualified Data.Conduit.Combinators as CC
459500
501+import Prelude
502+
503+-- | The following example uses minio's play server at
504+-- https://play.minio.io:9000. The endpoint and associated
505+-- credentials are provided via the libary constant,
506+--
507+-- > minioPlayCI :: ConnectInfo
508+--
509+
460510main :: IO ()
461511main = do
462512 let
463− bucket = "mybucket"
464− object = "myobject"
465− kb15 = 15 * 1024
466−
467− res <- runMinio minioPlayCI $ do
468− putObject bucket object (CC.repeat "a") (Just kb15)
513+ bucket = "test"
514+ object = "obj"
515+ localFile = "/etc/lsb-release"
516+ kb15 = 15 * 1024
469517
518+ -- Eg 1. Upload a stream of repeating "a" using putObject with default options.
519+ res <- runMinio minioPlayCI $
520+ putObject bucket object (CC.repeat "a") (Just kb15) def
470521 case res of
471− Left e -> putStrLn $ "Failed to putObject " ++ show bucket ++ "/" ++ show object
472− Right _ -> putStrLn "PutObject was successful"
522+ Left e -> putStrLn $ "putObject failed." ++ show e
523+ Right () -> putStrLn "putObject succeeded."
524+
473525```
474526
475527<a name="fGetObject"></a>
examples/BucketExists.hs+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/CopyObject.hs+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/FileUploader.hs+13−13
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs --package optparse-applicative --package filepath
2+-- stack --resolver lts-11.1 runghc --package minio-hs --package optparse-applicative --package filepath
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
@@ -22,13 +22,13 @@
2222{-# LANGUAGE ScopedTypeVariables #-}
2323import Network.Minio
2424
25−import Control.Monad.Catch (catchIf)
26−import Control.Monad.IO.Class (liftIO)
27−import Data.Monoid ((<>))
28−import Data.Text (pack)
25+import Data.Monoid ((<>))
26+import Data.Text (pack)
2927import Options.Applicative
30−import Prelude
3128import System.FilePath.Posix
29+import UnliftIO (throwIO, try)
30+
31+import Prelude
3232
3333-- | The following example uses minio's play server at
3434-- https://play.minio.io:9000. The endpoint and associated
@@ -50,10 +50,6 @@ cmdParser = info
5050 <> header
5151 "FileUploader - a simple file-uploader program using minio-hs")
5252
53−ignoreMinioErr :: ServiceErr -> Minio ()
54−ignoreMinioErr = return . const ()
55−
56−
5753main :: IO ()
5854main = do
5955 let bucket = "my-bucket"
@@ -64,10 +60,14 @@ main = do
6460
6561 res <- runMinio minioPlayCI $ do
6662 -- Make a bucket; catch bucket already exists exception if thrown.
67− catchIf (== BucketAlreadyOwnedByYou) (makeBucket bucket Nothing) ignoreMinioErr
63+ bErr <- try $ makeBucket bucket Nothing
64+ case bErr of
65+ Left (MErrService BucketAlreadyOwnedByYou) -> return ()
66+ Left e -> throwIO e
67+ Right _ -> return ()
6868
6969 -- Upload filepath to bucket; object is derived from filepath.
70− fPutObject bucket object filepath
70+ fPutObject bucket object filepath def
7171
7272 case res of
7373 Left e -> putStrLn $ "file upload failed due to " ++ (show e)
examples/GetConfig.hs+1−1
@@ -2,7 +2,7 @@
22-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2018 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/GetObject.hs+7−6
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
@@ -20,8 +20,9 @@
2020{-# LANGUAGE OverloadedStrings #-}
2121import Network.Minio
2222
23−import Data.Conduit (($$+-))
24−import Data.Conduit.Binary (sinkLbs)
23+import qualified Data.Conduit as C
24+import qualified Data.Conduit.Binary as CB
25+
2526import Prelude
2627
2728-- | The following example uses minio's play server at
@@ -37,8 +38,8 @@ main = do
3738 bucket = "my-bucket"
3839 object = "my-object"
3940 res <- runMinio minioPlayCI $ do
40− src <- getObject bucket object
41− (src $$+- sinkLbs)
41+ src <- getObject bucket object def
42+ C.connect src $ CB.sinkFileCautious "/tmp/my-object"
4243
4344 case res of
4445 Left e -> putStrLn $ "getObject failed." ++ (show e)
examples/HeadObject.hs+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/Heal.hs+1−1
@@ -2,7 +2,7 @@
22-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2018 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/ListBuckets.hs+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/ListIncompleteUploads.hs+4−5
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
@@ -20,8 +20,7 @@
2020{-# LANGUAGE OverloadedStrings #-}
2121import Network.Minio
2222
23−import Data.Conduit (($$))
24−import Data.Conduit.Combinators (sinkList)
23+import Conduit
2524import Prelude
2625
2726-- | The following example uses minio's play server at
@@ -39,7 +38,7 @@ main = do
3938 -- Performs a recursive listing of incomplete uploads under bucket "test"
4039 -- on a local minio server.
4140 res <- runMinio minioPlayCI $
42− listIncompleteUploads bucket Nothing True $$ sinkList
41+ runConduit $ listIncompleteUploads bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
4342 print res
4443
4544 {-
examples/ListObjects.hs+4−6
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
@@ -20,8 +20,7 @@
2020{-# LANGUAGE OverloadedStrings #-}
2121import Network.Minio
2222
23−import qualified Data.Conduit as C
24−import qualified Data.Conduit.Combinators as CC
23+import Conduit
2524import Prelude
2625
2726
@@ -40,9 +39,8 @@ main = do
4039 -- Performs a recursive listing of all objects under bucket "test"
4140 -- on play.minio.io.
4241 res <- runMinio minioPlayCI $
43− listObjects bucket Nothing True C.$$ CC.sinkList
42+ runConduit $ listObjects bucket Nothing True .| mapM_C (\v -> (liftIO $ print v))
4443 print res
45−
4644 {-
4745 Following is the output of the above program on a local Minio server.
4846
examples/Makebucket.hs → examples/MakeBucket.hsrenamed+3−4
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
@@ -32,8 +32,7 @@ import Prelude
3232
3333main :: IO ()
3434main = do
35− let
36− bucket = "my-bucket"
35+ let bucket = "my-bucket"
3736 res <- runMinio minioPlayCI $
3837 -- N B the region provided for makeBucket is optional.
3938 makeBucket bucket (Just "us-east-1")
examples/PresignedGetObject.hs+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/PresignedPostPolicy.hs+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/PresignedPutObject.hs+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/PutObject.hs+4−3
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@ import Network.Minio
2222
2323import qualified Data.Conduit.Combinators as CC
2424
25+import Prelude
26+
2527-- | The following example uses minio's play server at
2628-- https://play.minio.io:9000. The endpoint and associated
2729-- credentials are provided via the libary constant,
@@ -44,7 +46,6 @@ main = do
4446 Left e -> putStrLn $ "putObject failed." ++ show e
4547 Right () -> putStrLn "putObject succeeded."
4648
47−
4849 -- Eg 2. Upload a file using fPutObject with default options.
4950 res2 <- runMinio minioPlayCI $
5051 fPutObject bucket object localFile def
examples/Removebucket.hs → examples/RemoveBucket.hsrenamed+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/RemoveIncompleteUpload.hs+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/RemoveObject.hs+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env stack
2−-- stack --resolver lts-9.1 runghc --package minio-hs
2+-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2017 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/ServerInfo.hs+1−1
@@ -2,7 +2,7 @@
22-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2018 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
examples/SetConfig.hs+1−1
@@ -2,7 +2,7 @@
22-- stack --resolver lts-11.1 runghc --package minio-hs
33
44--
5−-- Minio Haskell SDK, (C) 2018 Minio, Inc.
5+-- Minio Haskell SDK, (C) 2017, 2018 Minio, Inc.
66--
77-- Licensed under the Apache License, Version 2.0 (the "License");
88-- you may not use this file except in compliance with the License.
src/Network/Minio/JsonParser.hs+2−2
@@ -38,5 +38,5 @@ instance FromJSON AdminErrJSON where
3838parseErrResponseJSON :: (MonadIO m) => LByteString -> m ServiceErr
3939parseErrResponseJSON jsondata =
4040 case eitherDecode jsondata of
41− Right (AdminErrJSON code message) -> return $ toServiceErr code message
42− Left err -> throwIO $ MErrVJsonParse $ T.pack err
41+ Right aErr -> return $ toServiceErr (aeCode aErr) (aeMessage aErr)
42+ Left err -> throwIO $ MErrVJsonParse $ T.pack err
src/Network/Minio/PutObject.hs+2−1
@@ -22,6 +22,7 @@ module Network.Minio.PutObject
2222 ) where
2323
2424
25+import Conduit (takeC)
2526import qualified Data.ByteString.Lazy as LBS
2627import qualified Data.Conduit as C
2728import qualified Data.Conduit.Binary as CB
@@ -68,7 +69,7 @@ putObjectInternal b o opts (ODStream src sizeMay) = do
6869 -- got file size, so check for single/multipart upload
6970 Just size ->
7071 if | size <= 64 * oneMiB -> do
71− bs <- C.runConduit $ src C..| CB.sinkLbs
72+ bs <- C.runConduit $ src C..| takeC (fromIntegral size) C..| CB.sinkLbs
7273 putObjectSingle' b o (pooToHeaders opts) $ LBS.toStrict bs
7374 | size > maxObjectSize -> throwIO $ MErrVPutSizeExceeded size
7475 | otherwise -> sequentialMultipartUpload b o opts (Just size) src