servant-multipart-client-0.12.2: multipart/form-data (e.g file upload) support for servant
Safe HaskellSafe-Inferred
LanguageHaskell2010

Servant.Multipart.Client

Description

multipart/form-data client-side support for servant. See servant-multipart-api for the API definitions.

Synopsis

Documentation

genBoundary :: IO ByteString Source #

Generates a boundary to be used to separate parts of the multipart. Requires IO because it is randomized.

class ToMultipart tag a where #

Allows you to tell servant how to turn a more structured type into a MultipartData, which is what is actually sent by the client.

  data User = User { username :: Text, pic :: FilePath }

  instance toMultipart Tmp User where
      toMultipart user = MultipartData [Input "username" $ username user]
                                       [FileData "pic"
                                                 (pic user)
                                                 "image/png"
                                                 (pic user)
                                       ]
  

Methods

toMultipart :: a -> MultipartData tag #

Given a value of type a, convert it to a MultipartData.

Instances

Instances details
ToMultipart tag (MultipartData tag) 
Instance details

Defined in Servant.Multipart.API

multipartToBody :: forall tag. MultipartClient tag => ByteString -> MultipartData tag -> RequestBody Source #

Given a bytestring for the boundary, turns a MultipartData into a RequestBody

Orphan instances

(ToMultipart tag a, HasClient m api, MultipartClient tag) => HasClient m (MultipartForm' mods tag a :> api) Source #

Upon seeing MultipartForm a :> ... in an API type, servant-client will take a parameter of type (LBS.ByteString, a), where the bytestring is the boundary to use (see genBoundary), and replace the request body with the contents of the form.

Instance details

Associated Types

type Client m (MultipartForm' mods tag a :> api) #

Methods

clientWithRoute :: Proxy m -> Proxy (MultipartForm' mods tag a :> api) -> Request -> Client m (MultipartForm' mods tag a :> api) #

hoistClientMonad :: Proxy m -> Proxy (MultipartForm' mods tag a :> api) -> (forall x. mon x -> mon' x) -> Client mon (MultipartForm' mods tag a :> api) -> Client mon' (MultipartForm' mods tag a :> api) #