GetObject s3api and fGetObject api
- Also updates to lts 6.27 (to be able to use sinkFileCautious)
This commit is contained in:
parent
fe1dfe24d6
commit
73a88143d5
@ -31,5 +31,7 @@ main = do
|
|||||||
res <- getLocation "test1"
|
res <- getLocation "test1"
|
||||||
print res
|
print res
|
||||||
|
|
||||||
|
fGetObject "test1" "passwd" "/tmp/passwd"
|
||||||
|
|
||||||
print "After runResourceT"
|
print "After runResourceT"
|
||||||
print t
|
print t
|
||||||
|
|||||||
@ -31,9 +31,12 @@ library
|
|||||||
, bytestring
|
, bytestring
|
||||||
, case-insensitive
|
, case-insensitive
|
||||||
, conduit
|
, conduit
|
||||||
|
, conduit-combinators
|
||||||
|
, conduit-extra
|
||||||
, containers
|
, containers
|
||||||
, cryptonite
|
, cryptonite
|
||||||
, errors
|
, errors
|
||||||
|
, filepath
|
||||||
, http-client
|
, http-client
|
||||||
, http-conduit
|
, http-conduit
|
||||||
, http-types
|
, http-types
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
module Network.Minio
|
module Network.Minio
|
||||||
( module Exports
|
( module Exports
|
||||||
|
, fGetObject
|
||||||
) where
|
) where
|
||||||
|
|
||||||
{-
|
{-
|
||||||
@ -19,3 +20,17 @@ import Network.Minio.Data as
|
|||||||
, connect
|
, connect
|
||||||
, ConnectInfo(..)
|
, ConnectInfo(..)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
import System.FilePath
|
||||||
|
import qualified Data.Conduit as C
|
||||||
|
import qualified Data.Conduit.Binary as CB
|
||||||
|
|
||||||
|
import Lib.Prelude
|
||||||
|
|
||||||
|
import Network.Minio.Data
|
||||||
|
import Network.Minio.S3API
|
||||||
|
|
||||||
|
fGetObject :: Bucket -> Object -> FilePath -> Minio ()
|
||||||
|
fGetObject bucket object fp = do
|
||||||
|
(_, src) <- getObject bucket object [] []
|
||||||
|
src C.$$+- CB.sinkFileCautious fp
|
||||||
|
|||||||
@ -5,6 +5,7 @@ module Network.Minio.API
|
|||||||
, RequestInfo(..)
|
, RequestInfo(..)
|
||||||
, runMinio
|
, runMinio
|
||||||
, executeRequest
|
, executeRequest
|
||||||
|
, mkStreamRequest
|
||||||
, requestInfo
|
, requestInfo
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -61,8 +62,9 @@ executeRequest ri = do
|
|||||||
|
|
||||||
NC.httpLbs req mgr
|
NC.httpLbs req mgr
|
||||||
|
|
||||||
mkSRequest :: RequestInfo -> Minio (Response (C.ResumableSource Minio ByteString))
|
mkStreamRequest :: RequestInfo
|
||||||
mkSRequest ri = do
|
-> Minio (Response (C.ResumableSource Minio ByteString))
|
||||||
|
mkStreamRequest ri = do
|
||||||
let PayloadSingle pload = payload ri
|
let PayloadSingle pload = payload ri
|
||||||
phash = hashSHA256 pload
|
phash = hashSHA256 pload
|
||||||
newRI = ri {
|
newRI = ri {
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
module Network.Minio.S3API
|
module Network.Minio.S3API
|
||||||
( getService
|
( getService
|
||||||
, getLocation
|
, getLocation
|
||||||
|
, getObject
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Network.HTTP.Types as HT
|
import qualified Network.HTTP.Types as HT
|
||||||
import qualified Network.HTTP.Conduit as NC
|
import qualified Network.HTTP.Conduit as NC
|
||||||
|
import qualified Data.Conduit as C
|
||||||
|
|
||||||
|
|
||||||
import Lib.Prelude
|
import Lib.Prelude
|
||||||
@ -27,4 +29,11 @@ getLocation bucket = do
|
|||||||
(PayloadSingle "")
|
(PayloadSingle "")
|
||||||
parseLocation $ NC.responseBody resp
|
parseLocation $ NC.responseBody resp
|
||||||
|
|
||||||
-- getObject ::
|
getObject :: Bucket -> Object -> HT.Query -> [HT.Header]
|
||||||
|
-> Minio ([HT.Header], C.ResumableSource Minio ByteString)
|
||||||
|
getObject bucket object queryParams headers = do
|
||||||
|
resp <- mkStreamRequest reqInfo
|
||||||
|
return $ (NC.responseHeaders resp, NC.responseBody resp)
|
||||||
|
where
|
||||||
|
reqInfo = requestInfo HT.methodGet (Just bucket) (Just object)
|
||||||
|
queryParams headers (PayloadSingle "")
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
# resolver:
|
# resolver:
|
||||||
# name: custom-snapshot
|
# name: custom-snapshot
|
||||||
# location: "./custom-snapshot.yaml"
|
# location: "./custom-snapshot.yaml"
|
||||||
resolver: lts-6.15
|
resolver: lts-6.27
|
||||||
|
|
||||||
# User packages to be built.
|
# User packages to be built.
|
||||||
# Various formats can be used as shown in the example below.
|
# Various formats can be used as shown in the example below.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user