Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Servant: upload file as multipart/form-data

What is the way to implement a file upload API with Servant? I am trying to handle "standard" multipart/form-data but cannot figure out how to declare it in Servant.

This obviously doesn't work as it cannot handle multiparts:

type API = "file" :> ReqBody '[OctetStream] ByteString :> Post '[OctetStream] ()

Does Servant support file uploads?

like image 603
Alexey Raga Avatar asked Mar 31 '26 15:03

Alexey Raga


1 Answers

This combinator works well. Just put it in a file in your app. https://github.com/haskell-servant/servant/issues/133#issuecomment-125235662

like image 68
Sean Clark Hess Avatar answered Apr 02 '26 21:04

Sean Clark Hess