Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Replacing IFormFile with a byte array in an POCO

$
0
0

Hi,

I have an HTTP server with a model which has an IFormFile attribute which I want to replace with a byte array. The HTTP Client sends a PUT request with follwing content disposition header:

"form-data;name=\"File\""

The body contains raw data.

On the server side I have following attribute in a POCO model:

public byte[] File{ get; set; }

Unfortunatelly this attribute is set to null on the server side. Does anyone have an idea how I can send raw data and receive it in a POCO model?

Why do I want to do this? I want to save the file into the database and I can't save directly an IFormFile into a database. Therefore I have to open a stream and copy it into an MemoryStream. Then I have to convert it into a byte array. The steps are described here and involve too much copying for my taste.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>