Hristo Hristo - 3 years ago 204
ASP.NET (C#) Question

Returning File() returns more bytes

Consider the following code:

//get bytes
var query = await _storage.Get(attachment.Id, General.ContainerType.Uploads);
//just for the sake of debugging
var mem = new MemoryStream(query);
//return the uploaded file
return File(mem, MimeTypesMap.GetMimeType(attachment.FileName), attachment.FileName);


After uploading a .jpg image of 67kb and then downloading it with this method, the returned image is 107 kb. I have checked whether the bytes are stored and retrieved correctly and they indeed are constistent with what I have uploaded. If I upload a text file and return it the content and the size is correct.

I assume File() does some magic, but I can't figure out why and what?

Answer Source

Resolved by providing a URL to the azure blob storage file and adding permissions for a few minutes : https://stackoverflow.com/a/30468172/4487530

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download