How to reupload image uploaded to server - Servant Haskell?

Viewed 63

I have an endpoint that allows users to upload an image to the server. I used Servant.Multipart MultipartFormData Tmp to achieve this. I need to reupload this to another service - something like s3 (currently using tmp.ninja for testing). I used multipart request in Req to do so and it works well. The problem I am facing is that in Servant.Multipart the uploaded image is stored in tmp folder with a .buf extension. So when I upload it to the storage API, it is not saved as image.

createRequest content = do
    multiPartBody <-  reqBodyMultipart [partFileSource "files[]" content]
    res <- req Network.HTTP.Req.POST (https "tmp.ninja" /: "upload.php") ( multiPartBody) jsonResponse mempty
    return (responseBody res:: UploadResponse)

and this is how I run it:

runReq defaultHttpConfig $createRequest (fdPayload file) 

where file is from the multipart request.

Is there a way to accomplish this without writing the file again as a png or jpeg

0 Answers
Related