public Stream GetImageContent(string id) { if (string.IsNullOrEmpty(id)) { return(null); } var objId = new ObjectId(); if (!ObjectId.TryParse(id, out objId)) { return(null); } var image = Get(id); if (string.IsNullOrEmpty(image.ContentId)) { return(null); } var content = new MemoryStream(); GridFs.DownloadToStream(ObjectId.Parse(image.ContentId), content); content.Position = 0; return(content); }
public Stream GetByContentId(string id) { var objId = new ObjectId(); if (!ObjectId.TryParse(id, out objId)) { return(null); } var content = new MemoryStream(); GridFs.DownloadToStream(ObjectId.Parse(id), content); content.Position = 0; return(content); }