The requirement is to show a thumbnail of all documents, such as pdf and ms-words, we store the documents in a database, we need to convert them to a file stream and display them as thumbnails.
At the moment I can display the image, because it is straightforward, I also have to display pdf images and text documents. I will show how I do for images
Controller:
public ActionResult File(int id) { var fileToRetrieve = db.File.Find(id); return File(fileToRetrieve.Content, fileToRetrieve.ContentType); }
View:
@foreach (var item in Model) { <div class="form-group"> <img src="~/Home/ File?id=@item.FileId " alt="avatar" width="100px" height="100x" /> </div> }
source share