Fix examples to point to lts-11.1 and update docs (#98)

This commit is contained in:
Harshavardhana 2018-06-08 15:44:55 -07:00 committed by Aditya Manthramurthy
parent 7564cbd514
commit 22808fcdaf
24 changed files with 210 additions and 141 deletions

View File

@ -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."
```

View File

@ -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
<a name="listObjects"></a>
### 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
```
<a name="listObjectsV1"></a>
### 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
```
<a name="listIncompleteUploads"></a>
@ -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
<a name="getObject"></a>
### 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."
```
<a name="putObject"></a>
### 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."
```
<a name="fGetObject"></a>

View File

@ -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.

View File

@ -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.

View File

@ -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)

View File

@ -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.

View File

@ -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)

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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
{-

View File

@ -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.

View File

@ -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")

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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