Hi @moondaddy ,
I have an API request where an image is uploaded in the in the request content as binary data. Is it possible to get the header's content-length value for this?
Based on your description, I think you have encapsulated the image data into DTO(Data Transfer Object). And if you want to get the Content-length, just get this parameter in Request: Request.Content.Headers.ContentLength
.
Here is a simple example:
[HttpPost]
public IHttpActionResult Upload([FromBody] ImageInfo image)
{
//get request content length
long? contentLength = Request.Content.Headers.ContentLength;
return Ok();
}
And the result like this:
Hope this can help you. But if I misunderstood anything, just let me know.
Best regards,
Xudong Peng
If the answer is the right solution, please click "Accept Answer" and kindly upvote. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.