Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created July 14, 2022 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/b1789ba403b492f674ab45796d22260a to your computer and use it in GitHub Desktop.
Save bjoerntx/b1789ba403b492f674ab45796d22260a to your computer and use it in GitHub Desktop.
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