MemoryStream memory = new MemoryStream();
bitmap.Save(memory, ImageFormat.Png);
var d = db.GridFS.Upload(memory, p.name);
What I'd like to be able to do is Create a GridFS file stream, and have the bitmap save directly into it, and tag the image with a version number and other information. Then I'd like to be able to query the file by name and version number and turn it back into a bitmap or stream.
I haven't found an example on how one would do this? Anyone have some advice?
Thanks,
John
MongoGridFSCreateOptions cOption = new MongoGridFSCreateOptions(); cOption.Metadata = (new { type = "gallery", sub_type = "original", w = w, format = format }).ToBsonDocument(); MongoGridFSFileInfo fi = myMongoGrid.Upload(myMemoryStream, nome_file, cOption); fi.Id.AsObjectId // your objectIdInserted // example query by ID and Resize Width and Format (jpeg,PNG) MongoGridFSFileInfo fi = myMongoGridFs.FindOne(Query.And(Query.EQ("metadata.OriginalId", new ObjectId(Id)), Query.EQ("metadata.w", w), Query.EQ("metadata.format", image_format))); Daniele