Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created January 11, 2018 00:10
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 dcomartin/4af5e91f4fe0aa0235544b99ad7bffd0 to your computer and use it in GitHub Desktop.
Save dcomartin/4af5e91f4fe0aa0235544b99ad7bffd0 to your computer and use it in GitHub Desktop.
// Upload a file from file system
db.FileStorage.Upload("$/photos/2014/picture-01.jpg", @"C:\Temp\picture-01.jpg");
// Upload a file from a Stream
db.FileStorage.Upload("$/photos/2014/picture-01.jpg", "picture-01.jpg", stream);
// Find file reference only - returns null if not found
LiteFileInfo file = db.FileStorage.FindById("$/photos/2014/picture-01.jpg");
// Now, load binary data and save to file system
file.SaveAs(@"C:\Temp\new-picture.jpg");
// Or get binary data as Stream and copy to another Stream
file.CopyTo(Response.OutputStream);
// Find all files references in a "directory"
var files = db.FileStorage.Find("$/photos/2014/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment