Skip to content

Instantly share code, notes, and snippets.

@weslley39
Created May 8, 2014 15:18
Show Gist options
  • Save weslley39/b025607b08351505e793 to your computer and use it in GitHub Desktop.
Save weslley39/b025607b08351505e793 to your computer and use it in GitHub Desktop.
Show Img Mongo C#
public FileContentResult MostraImagem(string id)
{
var imagem = FileService.BuscarPorId(id).OpenRead();
byte[] imagemEmBytes = new byte[imagem.Length];
using (BinaryReader leitor = new BinaryReader(imagem))
{
imagemEmBytes = leitor.ReadBytes((int)imagem.Length);
}
return new FileContentResult(imagemEmBytes, "image/jpeg");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment