GridFSDownloadStream.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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;
  16. using System.IO;
  17. using System.Threading;
  18. using System.Threading.Tasks;
  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. /// <typeparam name="TFileId">The type of the file identifier.</typeparam>
  25. public abstract class GridFSDownloadStream<TFileId> : Stream
  26. {
  27. // constructors
  28. internal GridFSDownloadStream()
  29. {
  30. }
  31. // public properties
  32. /// <summary>
  33. /// Gets the files collection document.
  34. /// </summary>
  35. /// <value>
  36. /// The files collection document.
  37. /// </value>
  38. public abstract GridFSFileInfo<TFileId> FileInfo { get; }
  39. // public methods
  40. #if NETSTANDARD1_5 || NETSTANDARD1_6 || NETCOREAPP
  41. /// <summary>
  42. /// Closes the GridFS stream.
  43. /// </summary>
  44. public virtual void Close()
  45. {
  46. Dispose(true);
  47. GC.SuppressFinalize(this);
  48. }
  49. #endif
  50. /// <summary>
  51. /// Closes the GridFS stream.
  52. /// </summary>
  53. /// <param name="cancellationToken">The cancellation token.</param>
  54. public abstract void Close(CancellationToken cancellationToken);
  55. /// <summary>
  56. /// Closes the GridFS stream.
  57. /// </summary>
  58. /// <param name="cancellationToken">The cancellation token.</param>
  59. /// <returns>A Task.</returns>
  60. public abstract Task CloseAsync(CancellationToken cancellationToken = default(CancellationToken));
  61. }
  62. }