Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }