Created
March 10, 2011 16:42
-
-
Save tgjones/864432 to your computer and use it in GitHub Desktop.
Example of Ormongo's GridFS wrapper class, Attachment
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 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