GridFSDownloadStreamCompat.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright 2016-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System.IO;
  16. using System.Threading;
  17. using System.Threading.Tasks;
  18. using MongoDB.Bson;
  19. namespace MongoDB.Driver.GridFS
  20. {
  21. /// <summary>
  22. /// Represents a Stream used by the application to read data from a GridFS file.
  23. /// </summary>
  24. public class GridFSDownloadStream : DelegatingStream
  25. {
  26. // fields
  27. private readonly GridFSDownloadStream<BsonValue> _wrappedStream;
  28. // constructors
  29. /// <summary>
  30. /// Initializes a new instance of the <see cref="GridFSDownloadStream"/> class.
  31. /// </summary>
  32. /// <param name="wrappedStream">The wrapped stream.</param>
  33. public GridFSDownloadStream(GridFSDownloadStream<BsonValue> wrappedStream)
  34. : base(wrappedStream)
  35. {
  36. _wrappedStream = wrappedStream;
  37. }
  38. // public properties
  39. /// <summary>
  40. /// Gets the files collection document.
  41. /// </summary>
  42. /// <value>
  43. /// The files collection document.
  44. /// </value>
  45. public GridFSFileInfo FileInfo
  46. {
  47. get
  48. {
  49. var wrappedFileInfo = _wrappedStream.FileInfo;
  50. return new GridFSFileInfo(wrappedFileInfo.BackingDocument);
  51. }
  52. }
  53. }
  54. }