IGridFSBucketCompat.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. using MongoDB.Bson;
  20. namespace MongoDB.Driver.GridFS
  21. {
  22. /// <summary>
  23. /// Represents a GridFS system bucket.
  24. /// </summary>
  25. public interface IGridFSBucket : IGridFSBucket<ObjectId>
  26. {
  27. // methods
  28. /// <summary>
  29. /// Finds matching entries from the files collection.
  30. /// </summary>
  31. /// <param name="filter">The filter.</param>
  32. /// <param name="options">The options.</param>
  33. /// <param name="cancellationToken">The cancellation token.</param>
  34. /// <returns>A cursor of files collection documents.</returns>
  35. IAsyncCursor<GridFSFileInfo> Find(FilterDefinition<GridFSFileInfo> filter, GridFSFindOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  36. /// <summary>
  37. /// Finds matching entries from the files collection.
  38. /// </summary>
  39. /// <param name="filter">The filter.</param>
  40. /// <param name="options">The options.</param>
  41. /// <param name="cancellationToken">The cancellation token.</param>
  42. /// <returns>A Task whose result is a cursor of files collection documents.</returns>
  43. Task<IAsyncCursor<GridFSFileInfo>> FindAsync(FilterDefinition<GridFSFileInfo> filter, GridFSFindOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  44. /// <summary>
  45. /// Opens a Stream that can be used by the application to write data to a GridFS file.
  46. /// </summary>
  47. /// <param name="filename">The filename.</param>
  48. /// <param name="options">The options.</param>
  49. /// <param name="cancellationToken">The cancellation token.</param>
  50. /// <returns>A Stream.</returns>
  51. GridFSUploadStream OpenUploadStream(string filename, GridFSUploadOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  52. /// <summary>
  53. /// Opens a Stream that can be used by the application to write data to a GridFS file.
  54. /// </summary>
  55. /// <param name="filename">The filename.</param>
  56. /// <param name="options">The options.</param>
  57. /// <param name="cancellationToken">The cancellation token.</param>
  58. /// <returns>A Task whose result is a Stream.</returns>
  59. Task<GridFSUploadStream> OpenUploadStreamAsync(string filename, GridFSUploadOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  60. /// <summary>
  61. /// Uploads a file (or a new revision of a file) to GridFS.
  62. /// </summary>
  63. /// <param name="filename">The filename.</param>
  64. /// <param name="source">The source.</param>
  65. /// <param name="options">The options.</param>
  66. /// <param name="cancellationToken">The cancellation token.</param>
  67. /// <returns>The id of the new file.</returns>
  68. ObjectId UploadFromBytes(string filename, byte[] source, GridFSUploadOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  69. /// <summary>
  70. /// Uploads a file (or a new revision of a file) to GridFS.
  71. /// </summary>
  72. /// <param name="filename">The filename.</param>
  73. /// <param name="source">The source.</param>
  74. /// <param name="options">The options.</param>
  75. /// <param name="cancellationToken">The cancellation token.</param>
  76. /// <returns>A Task whose result is the id of the new file.</returns>
  77. Task<ObjectId> UploadFromBytesAsync(string filename, byte[] source, GridFSUploadOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  78. /// <summary>
  79. /// Uploads a file (or a new revision of a file) to GridFS.
  80. /// </summary>
  81. /// <param name="filename">The filename.</param>
  82. /// <param name="source">The source.</param>
  83. /// <param name="options">The options.</param>
  84. /// <param name="cancellationToken">The cancellation token.</param>
  85. /// <returns>The id of the new file.</returns>
  86. ObjectId UploadFromStream(string filename, Stream source, GridFSUploadOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  87. /// <summary>
  88. /// Uploads a file (or a new revision of a file) to GridFS.
  89. /// </summary>
  90. /// <param name="filename">The filename.</param>
  91. /// <param name="source">The source.</param>
  92. /// <param name="options">The options.</param>
  93. /// <param name="cancellationToken">The cancellation token.</param>
  94. /// <returns>A Task whose result is the id of the new file.</returns>
  95. Task<ObjectId> UploadFromStreamAsync(string filename, Stream source, GridFSUploadOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  96. }
  97. }