diff --git a/.travis.yml b/.travis.yml index be4449d..ad53513 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,9 +36,5 @@ install: - stack --no-terminal --install-ghc test --only-dependencies script: -# Download Minio Server -- wget -q "https://dl.minio.io/server/minio/release/linux-amd64/minio" && chmod +x ./minio -# Run server in background. -- MINIO_ACCESS_KEY=minio MINIO_SECRET_KEY=minio123 ./minio server /tmp/export & # Build the package, its tests, and its docs and run the tests - stack --no-terminal test --haddock --no-haddock-deps diff --git a/README.md b/README.md index ecbbeb8..b0342e2 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,11 @@ stack test ``` -A section of the tests require a live Minio server, running on `http://localhost:9000` +A section of the tests use `https://play.minio.io:9000`. Documentation can be locally built with: - -``` shell +```sh stack haddock diff --git a/examples/putObject.hs b/examples/putObject.hs index dd81a39..25687b0 100755 --- a/examples/putObject.hs +++ b/examples/putObject.hs @@ -21,12 +21,12 @@ main = do object = "obj" mb15 = 15 * 1024 * 1024 - -- Eg 1. Upload a stream of repeating "a" using putObjectFromSource. + -- Eg 1. Upload a stream of repeating "a" using putObject. res1 <- runResourceT $ runMinio minioPlayCI $ do - putObjectFromSource bucket object (CC.repeat "a") (Just mb15) + putObject bucket object (CC.repeat "a") (Just mb15) case res1 of - Left e -> putStrLn $ "putObjectFromSource failed." ++ (show e) - Right () -> putStrLn "putObjectFromSource succeeded." + Left e -> putStrLn $ "putObject failed." ++ (show e) + Right () -> putStrLn "putObject succeeded." -- Eg 2. Upload a file using fPutObject. diff --git a/src/Network/Minio.hs b/src/Network/Minio.hs index 47e4b5a..aad9fea 100644 --- a/src/Network/Minio.hs +++ b/src/Network/Minio.hs @@ -43,7 +43,7 @@ module Network.Minio ---------------------- , fGetObject , fPutObject - , putObjectFromSource + , putObject , getObject , statObject @@ -75,7 +75,7 @@ fGetObject bucket object fp = do -- | Upload the given file to the given object. fPutObject :: Bucket -> Object -> FilePath -> Minio () -fPutObject bucket object f = void $ putObject bucket object $ +fPutObject bucket object f = void $ putObjectInternal bucket object $ ODFile f Nothing -- | Put an object from a conduit source. The size can be provided if @@ -83,9 +83,9 @@ fPutObject bucket object f = void $ putObject bucket object $ -- performing a multipart upload. If not specified, it is assumed that -- the object can be potentially 5TiB and selects multipart sizes -- appropriately. -putObjectFromSource :: Bucket -> Object -> C.Producer Minio ByteString +putObject :: Bucket -> Object -> C.Producer Minio ByteString -> Maybe Int64 -> Minio () -putObjectFromSource bucket object src sizeMay = void $ putObject bucket object $ +putObject bucket object src sizeMay = void $ putObjectInternal bucket object $ ODStream src sizeMay -- | Get an object from the object store as a resumable source (conduit). diff --git a/src/Network/Minio/PutObject.hs b/src/Network/Minio/PutObject.hs index 33132b2..33d2c71 100644 --- a/src/Network/Minio/PutObject.hs +++ b/src/Network/Minio/PutObject.hs @@ -1,6 +1,6 @@ module Network.Minio.PutObject ( - putObject + putObjectInternal , ObjectData(..) , selectPartSizes ) where @@ -49,9 +49,9 @@ data ObjectData m = ODFile FilePath (Maybe Int64) -- ^ Takes filepath and option -- | Put an object from ObjectData. This high-level API handles -- objects of all sizes, and even if the object size is unknown. -putObject :: Bucket -> Object -> ObjectData Minio -> Minio ETag -putObject b o (ODStream src sizeMay) = sequentialMultipartUpload b o sizeMay src -putObject b o (ODFile fp sizeMay) = do +putObjectInternal :: Bucket -> Object -> ObjectData Minio -> Minio ETag +putObjectInternal b o (ODStream src sizeMay) = sequentialMultipartUpload b o sizeMay src +putObjectInternal b o (ODFile fp sizeMay) = do hResE <- withNewHandle fp $ \h -> liftM2 (,) (isHandleSeekable h) (getFileSize h) diff --git a/test/LiveServer.hs b/test/LiveServer.hs index d2c5d85..e2db767 100644 --- a/test/LiveServer.hs +++ b/test/LiveServer.hs @@ -62,7 +62,7 @@ funTestWithBucket t minioTest = testCaseSteps t $ \step -> do bktSuffix <- liftIO $ generate $ Q.vectorOf 10 (Q.choose ('a', 'z')) let b = T.concat [funTestBucketPrefix, T.pack bktSuffix] liftStep = liftIO . step - ret <- runResourceT $ runMinio def $ do + ret <- runResourceT $ runMinio minioPlayCI $ do liftStep $ "Creating bucket for test - " ++ t makeBucket b def minioTest liftStep b @@ -136,7 +136,7 @@ liveServerUnitTests = testGroup "Unit tests against a live server" rFile <- mkRandFile mb100 step "Upload multipart file." - putObjectFromSource bucket obj (CB.sourceFile rFile) Nothing + putObject bucket obj (CB.sourceFile rFile) Nothing step "Retrieve and verify file size" destFile <- mkRandFile 0 @@ -154,7 +154,7 @@ liveServerUnitTests = testGroup "Unit tests against a live server" mb100 = 100 * 1024 * 1024 step "Upload multipart file." - void $ putObject bucket obj $ ODFile "/dev/zero" (Just mb100) + void $ putObjectInternal bucket obj $ ODFile "/dev/zero" (Just mb100) step "Retrieve and verify file size" destFile <- mkRandFile 0 @@ -198,7 +198,7 @@ liveServerUnitTests = testGroup "Unit tests against a live server" , funTestWithBucket "multipart" $ \step bucket -> do step "upload large object" - void $ putObject bucket "big" (ODFile "/dev/zero" $ Just $ 1024*1024*100) + void $ putObjectInternal bucket "big" (ODFile "/dev/zero" $ Just $ 1024*1024*100) step "cleanup" deleteObject bucket "big"