libZSamazonka-coreZSamazonka-core
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka.Data.Body

Description

 
Synopsis

Documentation

getFileSize :: MonadIO m => FilePath -> m Integer Source #

Convenience function for obtaining the size of a file.

newtype ResponseBody Source #

A streaming, exception safe response body.

Constructors

ResponseBody 

Instances

Instances details
Show ResponseBody Source # 
Instance details

Defined in Amazonka.Data.Body

sinkBody :: MonadIO m => ResponseBody -> ConduitM ByteString Void (ResourceT IO) a -> m a Source #

Connect a Sink to a response stream.

newtype ChunkSize Source #

Specifies the transmitted size of the 'Transfer-Encoding' chunks.

See: defaultChunk.

Constructors

ChunkSize Int 

Instances

Instances details
Enum ChunkSize Source # 
Instance details

Defined in Amazonka.Data.Body

Eq ChunkSize Source # 
Instance details

Defined in Amazonka.Data.Body

Integral ChunkSize Source # 
Instance details

Defined in Amazonka.Data.Body

Num ChunkSize Source # 
Instance details

Defined in Amazonka.Data.Body

Ord ChunkSize Source # 
Instance details

Defined in Amazonka.Data.Body

Real ChunkSize Source # 
Instance details

Defined in Amazonka.Data.Body

Show ChunkSize Source # 
Instance details

Defined in Amazonka.Data.Body

ToLog ChunkSize Source # 
Instance details

Defined in Amazonka.Data.Body

defaultChunkSize :: ChunkSize Source #

The default chunk size of 128 KB. The minimum chunk size accepted by AWS is 8 KB, unless the entirety of the request is below this threshold.

A chunk size of 64 KB or higher is recommended for performance reasons.

data ChunkedBody Source #

An opaque request body which will be transmitted via Transfer-Encoding: chunked.

Invariant: Only services that support chunked encoding can accept a ChunkedBody. (Currently S3.) This is enforced by the type signatures emitted by the generator.

Instances

Instances details
Show ChunkedBody Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody ChunkedBody Source # 
Instance details

Defined in Amazonka.Data.Body

chunkedFile :: MonadIO m => ChunkSize -> FilePath -> m RequestBody Source #

Construct a ChunkedBody from a FilePath, where the contents will be read and signed incrementally in chunks if the target service supports it.

Will intelligently revert to HashedBody if the file is smaller than the specified ChunkSize.

See: ToBody.

chunkedFileRange Source #

Arguments

:: MonadIO m 
=> ChunkSize

The idealized size of chunks that will be yielded downstream.

-> FilePath

The file path to read.

-> Integer

The byte offset at which to start reading.

-> Integer

The maximum number of bytes to read.

-> m RequestBody 

Construct a ChunkedBody from a FilePath, specifying the range of bytes to read. This can be useful for constructing multiple requests from a single file, say for S3 multipart uploads.

See: chunkedFile.

unsafeChunkedBody Source #

Arguments

:: ChunkSize

The idealized size of chunks that will be yielded downstream.

-> Integer

The size of the stream in bytes.

-> ConduitM () ByteString (ResourceT IO) () 
-> RequestBody 

Unsafely construct a ChunkedBody.

This function is marked unsafe because it does nothing to enforce the chunk size. Typically for conduit IO functions, it's whatever ByteString's defaultBufferSize is, around 32 KB. If the chunk size is less than 8 KB, the request will error. 64 KB or higher chunk size is recommended for performance reasons.

Note that it will always create a chunked body even if the request is too small.

See: ToBody.

sourceFileRangeChunks Source #

Arguments

:: MonadResource m 
=> ChunkSize

The idealized size of chunks that will be yielded downstream.

-> FilePath

The file path to read.

-> Integer

The byte offset at which to start reading.

-> Integer

The maximum number of bytes to read.

-> ConduitM () ByteString m () 

data HashedBody Source #

An opaque request body containing a SHA256 hash.

Instances

Instances details
Show HashedBody Source # 
Instance details

Defined in Amazonka.Data.Body

IsString HashedBody Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody HashedBody Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody HashedBody Source # 
Instance details

Defined in Amazonka.Data.Body

hashedFile Source #

Arguments

:: MonadIO m 
=> FilePath

The file path to read.

-> m HashedBody 

Construct a HashedBody from a FilePath, calculating the SHA256 hash and file size.

Note: While this function will perform in constant space, it will enumerate the entirety of the file contents _twice_. Firstly to calculate the SHA256 and lastly to stream the contents to the socket during sending.

See: ToHashedBody.

hashedFileRange Source #

Arguments

:: MonadIO m 
=> FilePath

The file path to read.

-> Integer

The byte offset at which to start reading.

-> Integer

The maximum number of bytes to read.

-> m HashedBody 

Construct a HashedBody from a FilePath, specifying the range of bytes to read. This can be useful for constructing multiple requests from a single file, say for S3 multipart uploads.

See: hashedFile, sourceFileRange.

hashedBody Source #

Arguments

:: Digest SHA256

A SHA256 hash of the file contents.

-> Integer

The size of the stream in bytes.

-> ConduitM () ByteString (ResourceT IO) () 
-> HashedBody 

Construct a HashedBody from a Source, manually specifying the SHA256 hash and file size. It's left up to the caller to calculate these correctly, otherwise AWS will return signing errors.

See: ToHashedBody.

data RequestBody Source #

Invariant: only services that support _both_ standard and chunked signing expose RequestBody as a parameter.

Instances

Instances details
Show RequestBody Source # 
Instance details

Defined in Amazonka.Data.Body

IsString RequestBody Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody RequestBody Source # 
Instance details

Defined in Amazonka.Data.Body

class ToHashedBody a where Source #

Anything that can be safely converted to a HashedBody.

Methods

toHashed :: a -> HashedBody Source #

Convert a value to a hashed request body.

Instances

Instances details
ToHashedBody String Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody ByteString Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody Text Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody Value Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody Element Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody ByteStringLazy Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody TextLazy Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody QueryString Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody HashedBody Source # 
Instance details

Defined in Amazonka.Data.Body

ToHashedBody Base64 Source # 
Instance details

Defined in Amazonka.Data.Base64

ToHashedBody (HashMap Text Value) Source # 
Instance details

Defined in Amazonka.Data.Body

class ToBody a where Source #

Anything that can be converted to a streaming request Body.

Minimal complete definition

Nothing

Methods

toBody :: a -> RequestBody Source #

Convert a value to a request body.

default toBody :: ToHashedBody a => a -> RequestBody Source #

Instances

Instances details
ToBody String Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody ByteString Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody Text Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody Value Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody Element Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody ByteStringLazy Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody TextLazy Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody QueryString Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody RequestBody Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody HashedBody Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody ChunkedBody Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody Base64 Source # 
Instance details

Defined in Amazonka.Data.Base64

ToHashedBody a => ToBody (Maybe a) Source # 
Instance details

Defined in Amazonka.Data.Body

ToBody a => ToBody (Sensitive a) Source # 
Instance details

Defined in Amazonka.Data.Sensitive

ToBody (HashMap Text Value) Source # 
Instance details

Defined in Amazonka.Data.Body