Last active
March 15, 2017 14:42
-
-
Save krisis/936eff42e5c78e29fe79f7b156d97219 to your computer and use it in GitHub Desktop.
Test case with 1001 parts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env stack | |
-- stack --resolver lts-6.27 runghc --package minio-hs --package optparse-applicative --package filepath | |
{-# Language OverloadedStrings, ScopedTypeVariables #-} | |
import Network.Minio | |
import Network.Minio.S3API | |
import Control.Monad (forM_) | |
import Control.Monad.Catch (catchIf) | |
import Data.ByteString (replicate) | |
import Data.Char (ord) | |
import Data.Conduit (($$)) | |
import Data.Conduit.Combinators (sinkList) | |
import Network.HTTP.Types.Header (hContentMD5) | |
import Prelude hiding (replicate) | |
ignoreMinioErr :: ServiceErr -> Minio () | |
ignoreMinioErr = return . const () | |
main :: IO () | |
main = do | |
let azureCI = def { | |
connectHost = "localhost" -- endpoint address where minio gateway is running | |
, connectPort = 9000 -- port where it is listening. | |
, connectAccessKey = "your azure access key" | |
, connectSecretKey = "your azure secret key" | |
} | |
bucket = "kp-hs-1" | |
object = "many-parts" | |
as = replicate (5*1024*1024) (fromIntegral $ ord 'a') | |
res <- runResourceT $ runMinio azureCI $ do | |
catchIf (== BucketAlreadyOwnedByYou) (makeBucket bucket Nothing) ignoreMinioErr | |
uploadID <- newMultipartUpload bucket object [] | |
liftIO $ print $ "uploadID: " ++ show uploadID | |
forM_ [1..2] $ \partNum -> do | |
putObjectPart bucket object uploadID partNum | |
[(hContentMD5, "79b281060d337b9b2b84ccf390adcf74")] $ | |
PayloadBS as | |
uploads <- listIncompleteUploads bucket (Just object) True $$ sinkList | |
let firstUpload = head uploads | |
liftIO $ putStrLn $ | |
"Size of the upload " ++ show (uiUploadId firstUpload) ++ " = " ++ | |
show (uiSize firstUpload) | |
case res of | |
Left e -> putStrLn $ "upload parts failed." ++ (show e) | |
Right _ -> putStrLn $ "upload parts succeeded" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also needed (at the time of writing) to install minio-hs from source at https://github.com/minio/minio as some recent (unreleased) fixes are required.