haskell-servant / servant-multipart

Support for file uploads in multipart/form-data for servant
https://hackage.haskell.org/package/servant-multipart
40 stars 37 forks source link

Documentation example not working around fdPayload #24

Closed FlogFr closed 5 years ago

FlogFr commented 5 years ago

Hello,

The following example documentation seems to be wrong:

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

  instance FromMultipart Tmp User where
    fromMultipart multipartData =
      User <$> lookupInput "username" multipartData
           <*> fmap fdPayload (lookupFile "pic" multipartData)

Available here: https://hackage.haskell.org/package/servant-multipart-0.11.3/docs/Servant-Multipart.html

The fdPayload returns a fdPayload :: MultipartResult tag and not a FilePath.

Can you confirm?

Thank you

alpmestan commented 5 years ago

MultipartResult tag resolves to FilePath when tag is Tmp and resolves to LBS.ByteString when tag is Mem. It's a type family, see https://hackage.haskell.org/package/servant-multipart-0.11.3/docs/src/Servant.Multipart.html#line-364 and https://hackage.haskell.org/package/servant-multipart-0.11.3/docs/src/Servant.Multipart.html#line-373.

FlogFr commented 5 years ago

Ok, sorry about that. Thank you for the explanation