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?
1 Answers
Answers 1
Its not about the File
but it is something to do with the MemoryStream
, for getting bytes stored in memorystream passing an entire stream is not appropriate way better to use its convenient ToArray()
method. You could try with the Binarywriter
0 comments:
Post a Comment