Skip to content

Instantly share code, notes, and snippets.

@tgjones
Created March 10, 2011 16:42
Show Gist options
  • Save tgjones/864432 to your computer and use it in GitHub Desktop.
Save tgjones/864432 to your computer and use it in GitHub Desktop.
Example of Ormongo's GridFS wrapper class, Attachment
public class Asset : Document<Asset>
{
public string Title { get; set; }
public Attachment File { get; set; }
}
Attachment file = Attachment.Create("Files/Koala.jpg", "image/jpg");
Asset asset = new Asset
{
Title = "The Title",
File = file
};
asset.Save();
/*
{
"_id": {
"$oid": "4d78ff2002df531d487fdbcc"
},
"_t": "Asset",
"Title": "The Title",
"File": {
"$oid": "4d78ff1f02df531d487fdbc6"
}
}
*/
Asset theAsset = Asset.FindByID(asset.ID);
string fileName = theAsset.File.FileName;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment