-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Generate multipart uploads for http-client.
--   
--   Generate multipart uploads for http-client.
@package http-client-multipart
@version 0.2.0.0


-- | This module handles building multipart/form-data. Example usage:
--   
--   <pre>
--   {-# LANGUAGE OverloadedStrings #-}
--   import Network
--   import Network.HTTP.Conduit
--   import Network.HTTP.Conduit.MultipartFormData
--   
--   import Data.Text.Encoding as TE
--   
--   import Control.Monad
--   
--   main = withSocketsDo $ withManager $ \m -&gt; do
--       req1 &lt;- parseUrl "http://random-cat-photo.net/cat.jpg"
--       res &lt;- httpLbs req1 m
--       req2 &lt;- parseUrl "http://example.org/~friedrich/blog/addPost.hs"
--       flip httpLbs m =&lt;&lt;
--           (formDataBody [partBS "title" "Bleaurgh"
--                         ,partBS "text" $ TE.encodeUtf8 "矢田矢田矢田矢田矢田"
--                         ,partFileSource "file1" "/home/friedrich/Photos/MyLittlePony.jpg"
--                         ,partFileRequestBody "file2" "cat.jpg" $ RequestBodyLBS $ responseBody res]
--               req2)
--   </pre>
module Network.HTTP.Client.MultipartFormData

-- | A single part of a multipart message.
data Part
Part :: Text -> Maybe String -> Maybe MimeType -> IO RequestBody -> Part

-- | Name of the corresponding &lt;input&gt;
partName :: Part -> Text

-- | A file name, if this is an attached file
partFilename :: Part -> Maybe String

-- | Content type
partContentType :: Part -> Maybe MimeType

-- | Action in m which returns the body of a message.
partGetBody :: Part -> IO RequestBody
partBS :: Text -> ByteString -> Part
partLBS :: Text -> ByteString -> Part

-- | Make a <a>Part</a> from a file, the entire file will reside in memory
--   at once. If you want constant memory usage use <a>partFileSource</a>
partFile :: Text -> FilePath -> Part

-- | Stream <a>Part</a> from a file.
partFileSource :: Text -> FilePath -> Part

-- | <a>partFileSourceChunked</a> will read a file and send it in chunks.
--   
--   Note that not all servers support this. Only use
--   <a>partFileSourceChunked</a> if you know the server you're sending to
--   supports chunked request bodies.
partFileSourceChunked :: Text -> FilePath -> Part

-- | Construct a <a>Part</a> from form name, filepath and a
--   <a>RequestBody</a>
--   
--   <pre>
--   partFileRequestBody "who_calls" "caller.json" $ RequestBodyBS "{\"caller\":\"Jason J Jason\"}"
--   </pre>
--   
--   <pre>
--   -- empty upload form
--   partFileRequestBody "file" mempty mempty
--   </pre>
partFileRequestBody :: Text -> FilePath -> RequestBody -> Part

-- | Construct a <a>Part</a> from action returning the <a>RequestBody</a>
--   
--   <pre>
--   partFileRequestBodyM "cat_photo" "haskell-the-cat.jpg" $ do
--       size &lt;- fromInteger &lt;$&gt; withBinaryFile "haskell-the-cat.jpg" ReadMode hFileSize
--       return $ RequestBodySource size $ CB.sourceFile "haskell-the-cat.jpg" $= CL.map fromByteString
--   </pre>
partFileRequestBodyM :: Text -> FilePath -> IO RequestBody -> Part

-- | Add form data to the <a>Request</a>.
--   
--   This sets a new <a>requestBody</a>, adds a content-type request header
--   and changes the method to POST.
formDataBody :: MonadIO m => [Part] -> Request -> m Request

-- | Add form data with supplied boundary
formDataBodyWithBoundary :: ByteString -> [Part] -> Request -> IO Request

-- | Generate a boundary simillar to those generated by WebKit-based
--   browsers.
webkitBoundary :: IO ByteString
webkitBoundaryPure :: RandomGen g => g -> (ByteString, g)

-- | Combine the <a>Part</a>s to form multipart/form-data body
renderParts :: ByteString -> [Part] -> IO RequestBody
renderPart :: ByteString -> Part -> IO RequestBody
instance Show Part
