Created
July 14, 2022 12:29
-
-
Save bjoerntx/b1789ba403b492f674ab45796d22260a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IActionResult View(string id) { | |
// retrieve document by id and return document as model | |
using (var db = new LiteDatabase("App_Data/MyData.db")) { | |
var fs = db.FileStorage; | |
using (MemoryStream ms = new MemoryStream()) { | |
fs.Download("$/documents/dummy_" + id + ".tx", ms); | |
var fileBytes = ms.ToArray(); | |
ViewDocument viewDoc = new ViewDocument() { | |
Name = "dummy" + id + ".tx", | |
BinaryData = Convert.ToBase64String(fileBytes) | |
}; | |
return View(viewDoc); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment