module Aws.S3.Commands.Multipart
where
import Aws.Aws
import Aws.Core
import Aws.S3.Core
import Control.Applicative
import Control.Arrow (second)
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.Resource
import qualified Crypto.Hash as CH
import Data.ByteString.Char8 ()
import Data.Conduit
import qualified Data.Conduit.List as CL
import Data.Maybe
import Text.XML.Cursor (($/))
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Lazy as BL
import qualified Data.CaseInsensitive as CI
import qualified Data.Map as M
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import qualified Network.HTTP.Conduit as HTTP
import qualified Network.HTTP.Types as HTTP
import qualified Text.XML as XML
import Prelude
data InitiateMultipartUpload
= InitiateMultipartUpload {
InitiateMultipartUpload -> Bucket
imuBucket :: Bucket
, InitiateMultipartUpload -> Bucket
imuObjectName :: Object
, InitiateMultipartUpload -> Maybe Bucket
imuCacheControl :: Maybe T.Text
, InitiateMultipartUpload -> Maybe Bucket
imuContentDisposition :: Maybe T.Text
, InitiateMultipartUpload -> Maybe Bucket
imuContentEncoding :: Maybe T.Text
, InitiateMultipartUpload -> Maybe Bucket
imuContentType :: Maybe T.Text
, InitiateMultipartUpload -> Maybe Int
imuExpires :: Maybe Int
, InitiateMultipartUpload -> [(Bucket, Bucket)]
imuMetadata :: [(T.Text,T.Text)]
, InitiateMultipartUpload -> Maybe StorageClass
imuStorageClass :: Maybe StorageClass
, InitiateMultipartUpload -> Maybe Bucket
imuWebsiteRedirectLocation :: Maybe T.Text
, InitiateMultipartUpload -> Maybe CannedAcl
imuAcl :: Maybe CannedAcl
, InitiateMultipartUpload -> Maybe ServerSideEncryption
imuServerSideEncryption :: Maybe ServerSideEncryption
, InitiateMultipartUpload -> Bool
imuAutoMakeBucket :: Bool
}
deriving (Int -> InitiateMultipartUpload -> ShowS
[InitiateMultipartUpload] -> ShowS
InitiateMultipartUpload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitiateMultipartUpload] -> ShowS
$cshowList :: [InitiateMultipartUpload] -> ShowS
show :: InitiateMultipartUpload -> String
$cshow :: InitiateMultipartUpload -> String
showsPrec :: Int -> InitiateMultipartUpload -> ShowS
$cshowsPrec :: Int -> InitiateMultipartUpload -> ShowS
Show)
postInitiateMultipartUpload :: Bucket -> T.Text -> InitiateMultipartUpload
postInitiateMultipartUpload :: Bucket -> Bucket -> InitiateMultipartUpload
postInitiateMultipartUpload Bucket
b Bucket
o =
Bucket
-> Bucket
-> Maybe Bucket
-> Maybe Bucket
-> Maybe Bucket
-> Maybe Bucket
-> Maybe Int
-> [(Bucket, Bucket)]
-> Maybe StorageClass
-> Maybe Bucket
-> Maybe CannedAcl
-> Maybe ServerSideEncryption
-> Bool
-> InitiateMultipartUpload
InitiateMultipartUpload
Bucket
b Bucket
o
forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing
[] forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing
Bool
False
data InitiateMultipartUploadResponse
= InitiateMultipartUploadResponse {
InitiateMultipartUploadResponse -> Bucket
imurBucket :: !Bucket
, InitiateMultipartUploadResponse -> Bucket
imurKey :: !T.Text
, InitiateMultipartUploadResponse -> Bucket
imurUploadId :: !T.Text
}
instance SignQuery InitiateMultipartUpload where
type ServiceConfiguration InitiateMultipartUpload = S3Configuration
signQuery :: forall queryType.
InitiateMultipartUpload
-> ServiceConfiguration InitiateMultipartUpload queryType
-> SignatureData
-> SignedQuery
signQuery InitiateMultipartUpload {Bool
[(Bucket, Bucket)]
Maybe Int
Maybe Bucket
Maybe ServerSideEncryption
Maybe StorageClass
Maybe CannedAcl
Bucket
imuAutoMakeBucket :: Bool
imuServerSideEncryption :: Maybe ServerSideEncryption
imuAcl :: Maybe CannedAcl
imuWebsiteRedirectLocation :: Maybe Bucket
imuStorageClass :: Maybe StorageClass
imuMetadata :: [(Bucket, Bucket)]
imuExpires :: Maybe Int
imuContentType :: Maybe Bucket
imuContentEncoding :: Maybe Bucket
imuContentDisposition :: Maybe Bucket
imuCacheControl :: Maybe Bucket
imuObjectName :: Bucket
imuBucket :: Bucket
imuAutoMakeBucket :: InitiateMultipartUpload -> Bool
imuServerSideEncryption :: InitiateMultipartUpload -> Maybe ServerSideEncryption
imuAcl :: InitiateMultipartUpload -> Maybe CannedAcl
imuWebsiteRedirectLocation :: InitiateMultipartUpload -> Maybe Bucket
imuStorageClass :: InitiateMultipartUpload -> Maybe StorageClass
imuMetadata :: InitiateMultipartUpload -> [(Bucket, Bucket)]
imuExpires :: InitiateMultipartUpload -> Maybe Int
imuContentType :: InitiateMultipartUpload -> Maybe Bucket
imuContentEncoding :: InitiateMultipartUpload -> Maybe Bucket
imuContentDisposition :: InitiateMultipartUpload -> Maybe Bucket
imuCacheControl :: InitiateMultipartUpload -> Maybe Bucket
imuObjectName :: InitiateMultipartUpload -> Bucket
imuBucket :: InitiateMultipartUpload -> Bucket
..} = forall qt.
S3Query -> S3Configuration qt -> SignatureData -> SignedQuery
s3SignQuery S3Query {
s3QMethod :: Method
s3QMethod = Method
Post
, s3QBucket :: Maybe ByteString
s3QBucket = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Bucket -> ByteString
T.encodeUtf8 Bucket
imuBucket
, s3QObject :: Maybe ByteString
s3QObject = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Bucket -> ByteString
T.encodeUtf8 forall a b. (a -> b) -> a -> b
$ Bucket
imuObjectName
, s3QSubresources :: [(ByteString, Maybe ByteString)]
s3QSubresources = forall a. QueryLike a => a -> [(ByteString, Maybe ByteString)]
HTTP.toQuery[ (ByteString
"uploads" :: B8.ByteString , forall a. Maybe a
Nothing :: Maybe B8.ByteString)]
, s3QQuery :: [(ByteString, Maybe ByteString)]
s3QQuery = []
, s3QContentType :: Maybe ByteString
s3QContentType = Bucket -> ByteString
T.encodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bucket
imuContentType
, s3QContentMd5 :: Maybe (Digest MD5)
s3QContentMd5 = forall a. Maybe a
Nothing
, s3QAmzHeaders :: RequestHeaders
s3QAmzHeaders = forall a b. (a -> b) -> [a] -> [b]
map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second Bucket -> ByteString
T.encodeUtf8) forall a b. (a -> b) -> a -> b
$ forall a. [Maybe a] -> [a]
catMaybes [
(CI ByteString
"x-amz-acl",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CannedAcl -> Bucket
writeCannedAcl forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe CannedAcl
imuAcl
, (CI ByteString
"x-amz-storage-class",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StorageClass -> Bucket
writeStorageClass forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe StorageClass
imuStorageClass
, (CI ByteString
"x-amz-website-redirect-location",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bucket
imuWebsiteRedirectLocation
, (CI ByteString
"x-amz-server-side-encryption",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ServerSideEncryption -> Bucket
writeServerSideEncryption forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe ServerSideEncryption
imuServerSideEncryption
, if Bool
imuAutoMakeBucket then forall a. a -> Maybe a
Just (CI ByteString
"x-amz-auto-make-bucket", Bucket
"1") else forall a. Maybe a
Nothing
] forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map( \(Bucket, Bucket)
x -> (forall s. FoldCase s => s -> CI s
CI.mk forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bucket -> ByteString
T.encodeUtf8 forall a b. (a -> b) -> a -> b
$ [Bucket] -> Bucket
T.concat [Bucket
"x-amz-meta-", forall a b. (a, b) -> a
fst (Bucket, Bucket)
x], forall a b. (a, b) -> b
snd (Bucket, Bucket)
x)) [(Bucket, Bucket)]
imuMetadata
, s3QOtherHeaders :: RequestHeaders
s3QOtherHeaders = forall a b. (a -> b) -> [a] -> [b]
map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second Bucket -> ByteString
T.encodeUtf8) forall a b. (a -> b) -> a -> b
$ forall a. [Maybe a] -> [a]
catMaybes [
(CI ByteString
"Expires",) forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Bucket
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Int
imuExpires
, (CI ByteString
"Cache-Control",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bucket
imuCacheControl
, (CI ByteString
"Content-Disposition",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bucket
imuContentDisposition
, (CI ByteString
"Content-Encoding",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bucket
imuContentEncoding
]
, s3QRequestBody :: Maybe RequestBody
s3QRequestBody = forall a. Maybe a
Nothing
}
instance ResponseConsumer r InitiateMultipartUploadResponse where
type ResponseMetadata InitiateMultipartUploadResponse = S3Metadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata InitiateMultipartUploadResponse)
-> HTTPResponseConsumer InitiateMultipartUploadResponse
responseConsumer Request
_ r
_ = forall a.
(Cursor -> Response S3Metadata a)
-> IORef S3Metadata -> HTTPResponseConsumer a
s3XmlResponseConsumer forall {m :: * -> *}.
MonadThrow m =>
Cursor -> m InitiateMultipartUploadResponse
parse
where parse :: Cursor -> m InitiateMultipartUploadResponse
parse Cursor
cursor
= do Bucket
bucket <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Bucket Name" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Bucket -> Cursor -> [Bucket]
elContent Bucket
"Bucket"
Bucket
key <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Key" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Bucket -> Cursor -> [Bucket]
elContent Bucket
"Key"
Bucket
uploadId <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing UploadID" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Bucket -> Cursor -> [Bucket]
elContent Bucket
"UploadId"
forall (m :: * -> *) a. Monad m => a -> m a
return InitiateMultipartUploadResponse{
imurBucket :: Bucket
imurBucket = Bucket
bucket
, imurKey :: Bucket
imurKey = Bucket
key
, imurUploadId :: Bucket
imurUploadId = Bucket
uploadId
}
instance Transaction InitiateMultipartUpload InitiateMultipartUploadResponse
instance AsMemoryResponse InitiateMultipartUploadResponse where
type MemoryResponse InitiateMultipartUploadResponse = InitiateMultipartUploadResponse
loadToMemory :: InitiateMultipartUploadResponse
-> ResourceT IO (MemoryResponse InitiateMultipartUploadResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return
data UploadPart = UploadPart {
UploadPart -> Bucket
upObjectName :: T.Text
, UploadPart -> Bucket
upBucket :: Bucket
, UploadPart -> Integer
upPartNumber :: Integer
, UploadPart -> Bucket
upUploadId :: T.Text
, UploadPart -> Maybe ByteString
upContentType :: Maybe B8.ByteString
, UploadPart -> Maybe (Digest MD5)
upContentMD5 :: Maybe (CH.Digest CH.MD5)
, UploadPart -> Maybe ServerSideEncryption
upServerSideEncryption :: Maybe ServerSideEncryption
, UploadPart -> RequestBody
upRequestBody :: HTTP.RequestBody
, UploadPart -> Bool
upExpect100Continue :: Bool
}
uploadPart :: Bucket -> T.Text -> Integer -> T.Text -> HTTP.RequestBody -> UploadPart
uploadPart :: Bucket -> Bucket -> Integer -> Bucket -> RequestBody -> UploadPart
uploadPart Bucket
bucket Bucket
obj Integer
p Bucket
i RequestBody
body =
Bucket
-> Bucket
-> Integer
-> Bucket
-> Maybe ByteString
-> Maybe (Digest MD5)
-> Maybe ServerSideEncryption
-> RequestBody
-> Bool
-> UploadPart
UploadPart Bucket
obj Bucket
bucket Integer
p Bucket
i
forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing RequestBody
body Bool
False
data UploadPartResponse
= UploadPartResponse {
UploadPartResponse -> Bucket
uprETag :: !T.Text
}
deriving (Int -> UploadPartResponse -> ShowS
[UploadPartResponse] -> ShowS
UploadPartResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UploadPartResponse] -> ShowS
$cshowList :: [UploadPartResponse] -> ShowS
show :: UploadPartResponse -> String
$cshow :: UploadPartResponse -> String
showsPrec :: Int -> UploadPartResponse -> ShowS
$cshowsPrec :: Int -> UploadPartResponse -> ShowS
Show)
instance SignQuery UploadPart where
type ServiceConfiguration UploadPart = S3Configuration
signQuery :: forall queryType.
UploadPart
-> ServiceConfiguration UploadPart queryType
-> SignatureData
-> SignedQuery
signQuery UploadPart {Bool
Integer
Maybe ByteString
Maybe (Digest MD5)
Maybe ServerSideEncryption
Bucket
RequestBody
upExpect100Continue :: Bool
upRequestBody :: RequestBody
upServerSideEncryption :: Maybe ServerSideEncryption
upContentMD5 :: Maybe (Digest MD5)
upContentType :: Maybe ByteString
upUploadId :: Bucket
upPartNumber :: Integer
upBucket :: Bucket
upObjectName :: Bucket
upExpect100Continue :: UploadPart -> Bool
upRequestBody :: UploadPart -> RequestBody
upServerSideEncryption :: UploadPart -> Maybe ServerSideEncryption
upContentMD5 :: UploadPart -> Maybe (Digest MD5)
upContentType :: UploadPart -> Maybe ByteString
upUploadId :: UploadPart -> Bucket
upPartNumber :: UploadPart -> Integer
upBucket :: UploadPart -> Bucket
upObjectName :: UploadPart -> Bucket
..} = forall qt.
S3Query -> S3Configuration qt -> SignatureData -> SignedQuery
s3SignQuery S3Query {
s3QMethod :: Method
s3QMethod = Method
Put
, s3QBucket :: Maybe ByteString
s3QBucket = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Bucket -> ByteString
T.encodeUtf8 Bucket
upBucket
, s3QObject :: Maybe ByteString
s3QObject = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Bucket -> ByteString
T.encodeUtf8 Bucket
upObjectName
, s3QSubresources :: [(ByteString, Maybe ByteString)]
s3QSubresources = forall a. QueryLike a => a -> [(ByteString, Maybe ByteString)]
HTTP.toQuery[
(ByteString
"partNumber" :: B8.ByteString , forall a. a -> Maybe a
Just (String -> Bucket
T.pack (forall a. Show a => a -> String
show Integer
upPartNumber)) :: Maybe T.Text)
, (ByteString
"uploadId" :: B8.ByteString, forall a. a -> Maybe a
Just Bucket
upUploadId :: Maybe T.Text)
]
, s3QQuery :: [(ByteString, Maybe ByteString)]
s3QQuery = []
, s3QContentType :: Maybe ByteString
s3QContentType = Maybe ByteString
upContentType
, s3QContentMd5 :: Maybe (Digest MD5)
s3QContentMd5 = Maybe (Digest MD5)
upContentMD5
, s3QAmzHeaders :: RequestHeaders
s3QAmzHeaders = forall a b. (a -> b) -> [a] -> [b]
map (forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second Bucket -> ByteString
T.encodeUtf8) forall a b. (a -> b) -> a -> b
$ forall a. [Maybe a] -> [a]
catMaybes [
(CI ByteString
"x-amz-server-side-encryption",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ServerSideEncryption -> Bucket
writeServerSideEncryption forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe ServerSideEncryption
upServerSideEncryption
]
, s3QOtherHeaders :: RequestHeaders
s3QOtherHeaders = forall a. [Maybe a] -> [a]
catMaybes [
if Bool
upExpect100Continue
then forall a. a -> Maybe a
Just (CI ByteString
"Expect", ByteString
"100-continue")
else forall a. Maybe a
Nothing
]
, s3QRequestBody :: Maybe RequestBody
s3QRequestBody = forall a. a -> Maybe a
Just RequestBody
upRequestBody
}
instance ResponseConsumer UploadPart UploadPartResponse where
type ResponseMetadata UploadPartResponse = S3Metadata
responseConsumer :: Request
-> UploadPart
-> IORef (ResponseMetadata UploadPartResponse)
-> HTTPResponseConsumer UploadPartResponse
responseConsumer Request
_ UploadPart
_ = forall a.
HTTPResponseConsumer a
-> IORef S3Metadata -> HTTPResponseConsumer a
s3ResponseConsumer forall a b. (a -> b) -> a -> b
$ \Response (ConduitM () ByteString (ResourceT IO) ())
resp -> do
let etag :: Bucket
etag = forall a. a -> Maybe a -> a
fromMaybe Bucket
"" forall a b. (a -> b) -> a -> b
$ ByteString -> Bucket
T.decodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup CI ByteString
"ETag" (forall body. Response body -> RequestHeaders
HTTP.responseHeaders Response (ConduitM () ByteString (ResourceT IO) ())
resp)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Bucket -> UploadPartResponse
UploadPartResponse Bucket
etag
instance Transaction UploadPart UploadPartResponse
instance AsMemoryResponse UploadPartResponse where
type MemoryResponse UploadPartResponse = UploadPartResponse
loadToMemory :: UploadPartResponse
-> ResourceT IO (MemoryResponse UploadPartResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return
data CompleteMultipartUpload
= CompleteMultipartUpload {
CompleteMultipartUpload -> Bucket
cmuBucket :: Bucket
, CompleteMultipartUpload -> Bucket
cmuObjectName :: Object
, CompleteMultipartUpload -> Bucket
cmuUploadId :: T.Text
, CompleteMultipartUpload -> [(Integer, Bucket)]
cmuPartNumberAndEtags :: [(Integer,T.Text)]
, CompleteMultipartUpload -> Maybe Bucket
cmuExpiration :: Maybe T.Text
, CompleteMultipartUpload -> Maybe Bucket
cmuServerSideEncryption :: Maybe T.Text
, CompleteMultipartUpload -> Maybe Bucket
cmuServerSideEncryptionCustomerAlgorithm :: Maybe T.Text
}
deriving (Int -> CompleteMultipartUpload -> ShowS
[CompleteMultipartUpload] -> ShowS
CompleteMultipartUpload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompleteMultipartUpload] -> ShowS
$cshowList :: [CompleteMultipartUpload] -> ShowS
show :: CompleteMultipartUpload -> String
$cshow :: CompleteMultipartUpload -> String
showsPrec :: Int -> CompleteMultipartUpload -> ShowS
$cshowsPrec :: Int -> CompleteMultipartUpload -> ShowS
Show)
postCompleteMultipartUpload :: Bucket -> T.Text -> T.Text -> [(Integer,T.Text)]-> CompleteMultipartUpload
postCompleteMultipartUpload :: Bucket
-> Bucket
-> Bucket
-> [(Integer, Bucket)]
-> CompleteMultipartUpload
postCompleteMultipartUpload Bucket
b Bucket
o Bucket
i [(Integer, Bucket)]
p = Bucket
-> Bucket
-> Bucket
-> [(Integer, Bucket)]
-> Maybe Bucket
-> Maybe Bucket
-> Maybe Bucket
-> CompleteMultipartUpload
CompleteMultipartUpload Bucket
b Bucket
o Bucket
i [(Integer, Bucket)]
p forall a. Maybe a
Nothing forall a. Maybe a
Nothing forall a. Maybe a
Nothing
data CompleteMultipartUploadResponse
= CompleteMultipartUploadResponse {
CompleteMultipartUploadResponse -> Bucket
cmurLocation :: !T.Text
, CompleteMultipartUploadResponse -> Bucket
cmurBucket :: !Bucket
, CompleteMultipartUploadResponse -> Bucket
cmurKey :: !T.Text
, CompleteMultipartUploadResponse -> Bucket
cmurETag :: !T.Text
, CompleteMultipartUploadResponse -> Maybe Bucket
cmurVersionId :: !(Maybe T.Text)
} deriving (Int -> CompleteMultipartUploadResponse -> ShowS
[CompleteMultipartUploadResponse] -> ShowS
CompleteMultipartUploadResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompleteMultipartUploadResponse] -> ShowS
$cshowList :: [CompleteMultipartUploadResponse] -> ShowS
show :: CompleteMultipartUploadResponse -> String
$cshow :: CompleteMultipartUploadResponse -> String
showsPrec :: Int -> CompleteMultipartUploadResponse -> ShowS
$cshowsPrec :: Int -> CompleteMultipartUploadResponse -> ShowS
Show)
instance SignQuery CompleteMultipartUpload where
type ServiceConfiguration CompleteMultipartUpload = S3Configuration
signQuery :: forall queryType.
CompleteMultipartUpload
-> ServiceConfiguration CompleteMultipartUpload queryType
-> SignatureData
-> SignedQuery
signQuery CompleteMultipartUpload {[(Integer, Bucket)]
Maybe Bucket
Bucket
cmuServerSideEncryptionCustomerAlgorithm :: Maybe Bucket
cmuServerSideEncryption :: Maybe Bucket
cmuExpiration :: Maybe Bucket
cmuPartNumberAndEtags :: [(Integer, Bucket)]
cmuUploadId :: Bucket
cmuObjectName :: Bucket
cmuBucket :: Bucket
cmuServerSideEncryptionCustomerAlgorithm :: CompleteMultipartUpload -> Maybe Bucket
cmuServerSideEncryption :: CompleteMultipartUpload -> Maybe Bucket
cmuExpiration :: CompleteMultipartUpload -> Maybe Bucket
cmuPartNumberAndEtags :: CompleteMultipartUpload -> [(Integer, Bucket)]
cmuUploadId :: CompleteMultipartUpload -> Bucket
cmuObjectName :: CompleteMultipartUpload -> Bucket
cmuBucket :: CompleteMultipartUpload -> Bucket
..} = forall qt.
S3Query -> S3Configuration qt -> SignatureData -> SignedQuery
s3SignQuery S3Query {
s3QMethod :: Method
s3QMethod = Method
Post
, s3QBucket :: Maybe ByteString
s3QBucket = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Bucket -> ByteString
T.encodeUtf8 Bucket
cmuBucket
, s3QObject :: Maybe ByteString
s3QObject = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Bucket -> ByteString
T.encodeUtf8 Bucket
cmuObjectName
, s3QSubresources :: [(ByteString, Maybe ByteString)]
s3QSubresources = forall a. QueryLike a => a -> [(ByteString, Maybe ByteString)]
HTTP.toQuery[
(ByteString
"uploadId" :: B8.ByteString, forall a. a -> Maybe a
Just Bucket
cmuUploadId :: Maybe T.Text)
]
, s3QQuery :: [(ByteString, Maybe ByteString)]
s3QQuery = []
, s3QContentType :: Maybe ByteString
s3QContentType = forall a. Maybe a
Nothing
, s3QContentMd5 :: Maybe (Digest MD5)
s3QContentMd5 = forall a. Maybe a
Nothing
, s3QAmzHeaders :: RequestHeaders
s3QAmzHeaders = forall a. [Maybe a] -> [a]
catMaybes [ (CI ByteString
"x-amz-expiration",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Bucket -> ByteString
T.encodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bucket
cmuExpiration)
, (CI ByteString
"x-amz-server-side-encryption",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Bucket -> ByteString
T.encodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bucket
cmuServerSideEncryption)
, (CI ByteString
"x-amz-server-side-encryption-customer-algorithm",)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Bucket -> ByteString
T.encodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bucket
cmuServerSideEncryptionCustomerAlgorithm)
]
, s3QOtherHeaders :: RequestHeaders
s3QOtherHeaders = []
, s3QRequestBody :: Maybe RequestBody
s3QRequestBody = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ ByteString -> RequestBody
HTTP.RequestBodyLBS ByteString
reqBody
}
where reqBody :: ByteString
reqBody = RenderSettings -> Document -> ByteString
XML.renderLBS forall a. Default a => a
XML.def XML.Document {
documentPrologue :: Prologue
XML.documentPrologue = [Miscellaneous] -> Maybe Doctype -> [Miscellaneous] -> Prologue
XML.Prologue [] forall a. Maybe a
Nothing []
, documentRoot :: Element
XML.documentRoot = Element
root
, documentEpilogue :: [Miscellaneous]
XML.documentEpilogue = []
}
root :: Element
root = XML.Element {
elementName :: Name
XML.elementName = Name
"CompleteMultipartUpload"
, elementAttributes :: Map Name Bucket
XML.elementAttributes = forall k a. Map k a
M.empty
, elementNodes :: [Node]
XML.elementNodes = (forall {a}. Show a => (a, Bucket) -> Node
partNode forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Integer, Bucket)]
cmuPartNumberAndEtags)
}
partNode :: (a, Bucket) -> Node
partNode (a
partNumber, Bucket
etag) = Element -> Node
XML.NodeElement XML.Element {
elementName :: Name
XML.elementName = Name
"Part"
, elementAttributes :: Map Name Bucket
XML.elementAttributes = forall k a. Map k a
M.empty
, elementNodes :: [Node]
XML.elementNodes = [Bucket -> Node
keyNode (String -> Bucket
T.pack (forall a. Show a => a -> String
show a
partNumber)),Bucket -> Node
etagNode Bucket
etag]
}
etagNode :: Bucket -> Node
etagNode = Name -> Bucket -> Node
toNode Name
"ETag"
keyNode :: Bucket -> Node
keyNode = Name -> Bucket -> Node
toNode Name
"PartNumber"
toNode :: Name -> Bucket -> Node
toNode Name
name Bucket
content = Element -> Node
XML.NodeElement XML.Element {
elementName :: Name
XML.elementName = Name
name
, elementAttributes :: Map Name Bucket
XML.elementAttributes = forall k a. Map k a
M.empty
, elementNodes :: [Node]
XML.elementNodes = [Bucket -> Node
XML.NodeContent Bucket
content]
}
instance ResponseConsumer r CompleteMultipartUploadResponse where
type ResponseMetadata CompleteMultipartUploadResponse = S3Metadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata CompleteMultipartUploadResponse)
-> HTTPResponseConsumer CompleteMultipartUploadResponse
responseConsumer Request
_ r
_ IORef (ResponseMetadata CompleteMultipartUploadResponse)
metadata Response (ConduitM () ByteString (ResourceT IO) ())
resp = forall a.
(Cursor -> Response S3Metadata a)
-> IORef S3Metadata -> HTTPResponseConsumer a
s3XmlResponseConsumer Cursor -> Response S3Metadata CompleteMultipartUploadResponse
parse IORef (ResponseMetadata CompleteMultipartUploadResponse)
metadata Response (ConduitM () ByteString (ResourceT IO) ())
resp
where vid :: Maybe Bucket
vid = ByteString -> Bucket
T.decodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup CI ByteString
"x-amz-version-id" (forall body. Response body -> RequestHeaders
HTTP.responseHeaders Response (ConduitM () ByteString (ResourceT IO) ())
resp)
parse :: Cursor -> Response S3Metadata CompleteMultipartUploadResponse
parse Cursor
cursor
= do Bucket
location <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Location" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Bucket -> Cursor -> [Bucket]
elContent Bucket
"Location"
Bucket
bucket <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Bucket Name" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Bucket -> Cursor -> [Bucket]
elContent Bucket
"Bucket"
Bucket
key <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Key" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Bucket -> Cursor -> [Bucket]
elContent Bucket
"Key"
Bucket
etag <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing ETag" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Bucket -> Cursor -> [Bucket]
elContent Bucket
"ETag"
forall (m :: * -> *) a. Monad m => a -> m a
return CompleteMultipartUploadResponse{
cmurLocation :: Bucket
cmurLocation = Bucket
location
, cmurBucket :: Bucket
cmurBucket = Bucket
bucket
, cmurKey :: Bucket
cmurKey = Bucket
key
, cmurETag :: Bucket
cmurETag = Bucket
etag
, cmurVersionId :: Maybe Bucket
cmurVersionId = Maybe Bucket
vid
}
instance Transaction CompleteMultipartUpload CompleteMultipartUploadResponse
instance AsMemoryResponse CompleteMultipartUploadResponse where
type MemoryResponse CompleteMultipartUploadResponse = CompleteMultipartUploadResponse
loadToMemory :: CompleteMultipartUploadResponse
-> ResourceT IO (MemoryResponse CompleteMultipartUploadResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return
data AbortMultipartUpload
= AbortMultipartUpload {
AbortMultipartUpload -> Bucket
amuBucket :: Bucket
, AbortMultipartUpload -> Bucket
amuObjectName :: Object
, AbortMultipartUpload -> Bucket
amuUploadId :: T.Text
}
deriving (Int -> AbortMultipartUpload -> ShowS
[AbortMultipartUpload] -> ShowS
AbortMultipartUpload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbortMultipartUpload] -> ShowS
$cshowList :: [AbortMultipartUpload] -> ShowS
show :: AbortMultipartUpload -> String
$cshow :: AbortMultipartUpload -> String
showsPrec :: Int -> AbortMultipartUpload -> ShowS
$cshowsPrec :: Int -> AbortMultipartUpload -> ShowS
Show)
postAbortMultipartUpload :: Bucket -> T.Text -> T.Text -> AbortMultipartUpload
postAbortMultipartUpload :: Bucket -> Bucket -> Bucket -> AbortMultipartUpload
postAbortMultipartUpload Bucket
b Bucket
o Bucket
i = Bucket -> Bucket -> Bucket -> AbortMultipartUpload
AbortMultipartUpload Bucket
b Bucket
o Bucket
i
data AbortMultipartUploadResponse
= AbortMultipartUploadResponse {
} deriving (Int -> AbortMultipartUploadResponse -> ShowS
[AbortMultipartUploadResponse] -> ShowS
AbortMultipartUploadResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbortMultipartUploadResponse] -> ShowS
$cshowList :: [AbortMultipartUploadResponse] -> ShowS
show :: AbortMultipartUploadResponse -> String
$cshow :: AbortMultipartUploadResponse -> String
showsPrec :: Int -> AbortMultipartUploadResponse -> ShowS
$cshowsPrec :: Int -> AbortMultipartUploadResponse -> ShowS
Show)
instance SignQuery AbortMultipartUpload where
type ServiceConfiguration AbortMultipartUpload = S3Configuration
signQuery :: forall queryType.
AbortMultipartUpload
-> ServiceConfiguration AbortMultipartUpload queryType
-> SignatureData
-> SignedQuery
signQuery AbortMultipartUpload {Bucket
amuUploadId :: Bucket
amuObjectName :: Bucket
amuBucket :: Bucket
amuUploadId :: AbortMultipartUpload -> Bucket
amuObjectName :: AbortMultipartUpload -> Bucket
amuBucket :: AbortMultipartUpload -> Bucket
..} = forall qt.
S3Query -> S3Configuration qt -> SignatureData -> SignedQuery
s3SignQuery S3Query {
s3QMethod :: Method
s3QMethod = Method
Delete
, s3QBucket :: Maybe ByteString
s3QBucket = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Bucket -> ByteString
T.encodeUtf8 Bucket
amuBucket
, s3QObject :: Maybe ByteString
s3QObject = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Bucket -> ByteString
T.encodeUtf8 Bucket
amuObjectName
, s3QSubresources :: [(ByteString, Maybe ByteString)]
s3QSubresources = forall a. QueryLike a => a -> [(ByteString, Maybe ByteString)]
HTTP.toQuery[
(ByteString
"uploadId" :: B8.ByteString, forall a. a -> Maybe a
Just Bucket
amuUploadId :: Maybe T.Text)
]
, s3QQuery :: [(ByteString, Maybe ByteString)]
s3QQuery = []
, s3QContentType :: Maybe ByteString
s3QContentType = forall a. Maybe a
Nothing
, s3QContentMd5 :: Maybe (Digest MD5)
s3QContentMd5 = forall a. Maybe a
Nothing
, s3QAmzHeaders :: RequestHeaders
s3QAmzHeaders = []
, s3QOtherHeaders :: RequestHeaders
s3QOtherHeaders = []
, s3QRequestBody :: Maybe RequestBody
s3QRequestBody = forall a. Maybe a
Nothing
}
instance ResponseConsumer r AbortMultipartUploadResponse where
type ResponseMetadata AbortMultipartUploadResponse = S3Metadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata AbortMultipartUploadResponse)
-> HTTPResponseConsumer AbortMultipartUploadResponse
responseConsumer Request
_ r
_ = forall a.
(Cursor -> Response S3Metadata a)
-> IORef S3Metadata -> HTTPResponseConsumer a
s3XmlResponseConsumer forall {m :: * -> *} {p}.
Monad m =>
p -> m AbortMultipartUploadResponse
parse
where parse :: p -> m AbortMultipartUploadResponse
parse p
_cursor
= forall (m :: * -> *) a. Monad m => a -> m a
return AbortMultipartUploadResponse {}
instance Transaction AbortMultipartUpload AbortMultipartUploadResponse
instance AsMemoryResponse AbortMultipartUploadResponse where
type MemoryResponse AbortMultipartUploadResponse = AbortMultipartUploadResponse
loadToMemory :: AbortMultipartUploadResponse
-> ResourceT IO (MemoryResponse AbortMultipartUploadResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return
getUploadId ::
Configuration
-> S3Configuration NormalQuery
-> HTTP.Manager
-> T.Text
-> T.Text
-> IO T.Text
getUploadId :: Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> IO Bucket
getUploadId Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object = do
InitiateMultipartUploadResponse {
imurBucket :: InitiateMultipartUploadResponse -> Bucket
imurBucket = Bucket
_bucket
, imurKey :: InitiateMultipartUploadResponse -> Bucket
imurKey = Bucket
_object'
, imurUploadId :: InitiateMultipartUploadResponse -> Bucket
imurUploadId = Bucket
uploadId
} <- forall r a (io :: * -> *).
(Transaction r a, AsMemoryResponse a, MonadIO io) =>
Configuration
-> ServiceConfiguration r NormalQuery
-> Manager
-> r
-> io (MemoryResponse a)
memoryAws Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr forall a b. (a -> b) -> a -> b
$ Bucket -> Bucket -> InitiateMultipartUpload
postInitiateMultipartUpload Bucket
bucket Bucket
object
forall (m :: * -> *) a. Monad m => a -> m a
return Bucket
uploadId
sendEtag ::
Configuration
-> S3Configuration NormalQuery
-> HTTP.Manager
-> T.Text
-> T.Text
-> T.Text
-> [T.Text]
-> IO CompleteMultipartUploadResponse
sendEtag :: Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> Bucket
-> [Bucket]
-> IO CompleteMultipartUploadResponse
sendEtag Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object Bucket
uploadId [Bucket]
etags = do
forall r a (io :: * -> *).
(Transaction r a, AsMemoryResponse a, MonadIO io) =>
Configuration
-> ServiceConfiguration r NormalQuery
-> Manager
-> r
-> io (MemoryResponse a)
memoryAws Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr forall a b. (a -> b) -> a -> b
$
Bucket
-> Bucket
-> Bucket
-> [(Integer, Bucket)]
-> CompleteMultipartUpload
postCompleteMultipartUpload Bucket
bucket Bucket
object Bucket
uploadId (forall a b. [a] -> [b] -> [(a, b)]
zip [Integer
1..] [Bucket]
etags)
putConduit ::
MonadResource m =>
Configuration
-> S3Configuration NormalQuery
-> HTTP.Manager
-> T.Text
-> T.Text
-> T.Text
-> ConduitT BL.ByteString T.Text m ()
putConduit :: forall (m :: * -> *).
MonadResource m =>
Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> Bucket
-> ConduitT ByteString Bucket m ()
putConduit Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object Bucket
uploadId = Integer -> ConduitT ByteString Bucket m ()
loop Integer
1
where
loop :: Integer -> ConduitT ByteString Bucket m ()
loop Integer
n = do
Maybe ByteString
v' <- forall (m :: * -> *) i o. Monad m => ConduitT i o m (Maybe i)
await
case Maybe ByteString
v' of
Just ByteString
v -> do
UploadPartResponse Bucket
etag <- forall r a (io :: * -> *).
(Transaction r a, AsMemoryResponse a, MonadIO io) =>
Configuration
-> ServiceConfiguration r NormalQuery
-> Manager
-> r
-> io (MemoryResponse a)
memoryAws Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr forall a b. (a -> b) -> a -> b
$
Bucket -> Bucket -> Integer -> Bucket -> RequestBody -> UploadPart
uploadPart Bucket
bucket Bucket
object Integer
n Bucket
uploadId (ByteString -> RequestBody
HTTP.RequestBodyLBS ByteString
v)
forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
yield Bucket
etag
Integer -> ConduitT ByteString Bucket m ()
loop (Integer
nforall a. Num a => a -> a -> a
+Integer
1)
Maybe ByteString
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
chunkedConduit :: (MonadResource m) => Integer -> ConduitT B8.ByteString BL.ByteString m ()
chunkedConduit :: forall (m :: * -> *).
MonadResource m =>
Integer -> ConduitT ByteString ByteString m ()
chunkedConduit Integer
size = forall (m :: * -> *).
Monad m =>
Integer -> [ByteString] -> ConduitT ByteString ByteString m ()
loop Integer
0 []
where
loop :: Monad m => Integer -> [B8.ByteString] -> ConduitT B8.ByteString BL.ByteString m ()
loop :: forall (m :: * -> *).
Monad m =>
Integer -> [ByteString] -> ConduitT ByteString ByteString m ()
loop Integer
cnt [ByteString]
str = forall (m :: * -> *) i o. Monad m => ConduitT i o m (Maybe i)
await forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (m :: * -> *) i.
Monad m =>
[ByteString] -> ConduitT i ByteString m ()
yieldChunk [ByteString]
str) forall (m :: * -> *).
Monad m =>
ByteString -> ConduitT ByteString ByteString m ()
go
where
go :: Monad m => B8.ByteString -> ConduitT B8.ByteString BL.ByteString m ()
go :: forall (m :: * -> *).
Monad m =>
ByteString -> ConduitT ByteString ByteString m ()
go ByteString
line
| Integer
size forall a. Ord a => a -> a -> Bool
<= Integer
len = forall (m :: * -> *) i.
Monad m =>
[ByteString] -> ConduitT i ByteString m ()
yieldChunk [ByteString]
newStr forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *).
Monad m =>
Integer -> [ByteString] -> ConduitT ByteString ByteString m ()
loop Integer
0 []
| Bool
otherwise = forall (m :: * -> *).
Monad m =>
Integer -> [ByteString] -> ConduitT ByteString ByteString m ()
loop Integer
len [ByteString]
newStr
where
len :: Integer
len = forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B8.length ByteString
line) forall a. Num a => a -> a -> a
+ Integer
cnt
newStr :: [ByteString]
newStr = ByteString
lineforall a. a -> [a] -> [a]
:[ByteString]
str
yieldChunk :: Monad m => [B8.ByteString] -> ConduitT i BL.ByteString m ()
yieldChunk :: forall (m :: * -> *) i.
Monad m =>
[ByteString] -> ConduitT i ByteString m ()
yieldChunk = forall (m :: * -> *) o i. Monad m => o -> ConduitT i o m ()
yield forall b c a. (b -> c) -> (a -> b) -> a -> c
. [ByteString] -> ByteString
BL.fromChunks forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> [a]
reverse
multipartUpload ::
Configuration
-> S3Configuration NormalQuery
-> HTTP.Manager
-> T.Text
-> T.Text
-> ConduitT () B8.ByteString (ResourceT IO) ()
-> Integer
-> ResourceT IO ()
multipartUpload :: Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> ConduitM () ByteString (ResourceT IO) ()
-> Integer
-> ResourceT IO ()
multipartUpload Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object ConduitM () ByteString (ResourceT IO) ()
src Integer
chunkSize = do
Bucket
uploadId <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> IO Bucket
getUploadId Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object
[Bucket]
etags <- (ConduitM () ByteString (ResourceT IO) ()
src
forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *).
MonadResource m =>
Integer -> ConduitT ByteString ByteString m ()
chunkedConduit Integer
chunkSize
forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *).
MonadResource m =>
Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> Bucket
-> ConduitT ByteString Bucket m ()
putConduit Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object Bucket
uploadId
) forall (m :: * -> *) a r.
Monad m =>
ConduitT () a m () -> ConduitT a Void m r -> m r
`connect` forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
CL.consume
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> Bucket
-> [Bucket]
-> IO CompleteMultipartUploadResponse
sendEtag Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object Bucket
uploadId [Bucket]
etags
multipartUploadSink :: MonadResource m
=> Configuration
-> S3Configuration NormalQuery
-> HTTP.Manager
-> T.Text
-> T.Text
-> Integer
-> ConduitT B8.ByteString Void m ()
multipartUploadSink :: forall (m :: * -> *).
MonadResource m =>
Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> Integer
-> ConduitT ByteString Void m ()
multipartUploadSink Configuration
cfg S3Configuration NormalQuery
s3cfg = forall (m :: * -> *).
MonadResource m =>
Configuration
-> S3Configuration NormalQuery
-> (Bucket -> Bucket -> InitiateMultipartUpload)
-> Manager
-> Bucket
-> Bucket
-> Integer
-> ConduitT ByteString Void m ()
multipartUploadSinkWithInitiator Configuration
cfg S3Configuration NormalQuery
s3cfg Bucket -> Bucket -> InitiateMultipartUpload
postInitiateMultipartUpload
multipartUploadWithInitiator ::
Configuration
-> S3Configuration NormalQuery
-> (Bucket -> T.Text -> InitiateMultipartUpload)
-> HTTP.Manager
-> T.Text
-> T.Text
-> ConduitT () B8.ByteString (ResourceT IO) ()
-> Integer
-> ResourceT IO ()
multipartUploadWithInitiator :: Configuration
-> S3Configuration NormalQuery
-> (Bucket -> Bucket -> InitiateMultipartUpload)
-> Manager
-> Bucket
-> Bucket
-> ConduitM () ByteString (ResourceT IO) ()
-> Integer
-> ResourceT IO ()
multipartUploadWithInitiator Configuration
cfg S3Configuration NormalQuery
s3cfg Bucket -> Bucket -> InitiateMultipartUpload
initiator Manager
mgr Bucket
bucket Bucket
object ConduitM () ByteString (ResourceT IO) ()
src Integer
chunkSize = do
Bucket
uploadId <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ InitiateMultipartUploadResponse -> Bucket
imurUploadId forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r a (io :: * -> *).
(Transaction r a, AsMemoryResponse a, MonadIO io) =>
Configuration
-> ServiceConfiguration r NormalQuery
-> Manager
-> r
-> io (MemoryResponse a)
memoryAws Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr (Bucket -> Bucket -> InitiateMultipartUpload
initiator Bucket
bucket Bucket
object)
[Bucket]
etags <- (ConduitM () ByteString (ResourceT IO) ()
src
forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *).
MonadResource m =>
Integer -> ConduitT ByteString ByteString m ()
chunkedConduit Integer
chunkSize
forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *).
MonadResource m =>
Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> Bucket
-> ConduitT ByteString Bucket m ()
putConduit Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object Bucket
uploadId
) forall (m :: * -> *) a r.
Monad m =>
ConduitT () a m () -> ConduitT a Void m r -> m r
`connect` forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
CL.consume
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> Bucket
-> [Bucket]
-> IO CompleteMultipartUploadResponse
sendEtag Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object Bucket
uploadId [Bucket]
etags
multipartUploadSinkWithInitiator :: MonadResource m
=> Configuration
-> S3Configuration NormalQuery
-> (Bucket -> T.Text -> InitiateMultipartUpload)
-> HTTP.Manager
-> T.Text
-> T.Text
-> Integer
-> ConduitT B8.ByteString Void m ()
multipartUploadSinkWithInitiator :: forall (m :: * -> *).
MonadResource m =>
Configuration
-> S3Configuration NormalQuery
-> (Bucket -> Bucket -> InitiateMultipartUpload)
-> Manager
-> Bucket
-> Bucket
-> Integer
-> ConduitT ByteString Void m ()
multipartUploadSinkWithInitiator Configuration
cfg S3Configuration NormalQuery
s3cfg Bucket -> Bucket -> InitiateMultipartUpload
initiator Manager
mgr Bucket
bucket Bucket
object Integer
chunkSize = do
Bucket
uploadId <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ InitiateMultipartUploadResponse -> Bucket
imurUploadId forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall r a (io :: * -> *).
(Transaction r a, AsMemoryResponse a, MonadIO io) =>
Configuration
-> ServiceConfiguration r NormalQuery
-> Manager
-> r
-> io (MemoryResponse a)
memoryAws Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr (Bucket -> Bucket -> InitiateMultipartUpload
initiator Bucket
bucket Bucket
object)
[Bucket]
etags <- forall (m :: * -> *).
MonadResource m =>
Integer -> ConduitT ByteString ByteString m ()
chunkedConduit Integer
chunkSize
forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *).
MonadResource m =>
Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> Bucket
-> ConduitT ByteString Bucket m ()
putConduit Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object Bucket
uploadId
forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) a o. Monad m => ConduitT a o m [a]
CL.consume
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ Configuration
-> S3Configuration NormalQuery
-> Manager
-> Bucket
-> Bucket
-> Bucket
-> [Bucket]
-> IO CompleteMultipartUploadResponse
sendEtag Configuration
cfg S3Configuration NormalQuery
s3cfg Manager
mgr Bucket
bucket Bucket
object Bucket
uploadId [Bucket]
etags