Example #1
0
        public Stream Get(string key)
        {
            var stream = new MemoryStream();

            _fs.DownloadToStream(ObjectId.Parse(key), stream);
            stream.Position = 0;
            return(stream);
        }
        private void DownloadingFile(string id, Stream destination)
        {
            IGridFSBucket bucket = GetGridFSBucket();

            ObjectId objectId = new ObjectId(id);

            bucket.DownloadToStream(objectId, destination);  //The driver does not close the Stream when it is done.
        }
Example #3
0
        public void GetFile(ObjectId id, Stream destination)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            _gridFsBucket.DownloadToStream(id, destination);
        }