I'm wondering how I can send a zip file to a WebApi controller and vice versa. The problem is that my WebApi uses json to transmit data. A zip file is not serializable, either is a stream. A string would be serializable. But there has to be an other solution than to convert the zip into a string and than send the string. That just sounds wrong.
Any idea how this is done?
Try using a simple HttpResponseMessage, with a StreamContent inside to GET, download file
and for POST, upload file
If your API method expects an
HttpRequestMessage
then you can pull the stream from that:This works for me when posting an HTTP form with
enctype="multipart/form-data"
.