GridFSUploadOptions.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* Copyright 2015-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.Collections.Generic;
  17. using MongoDB.Bson;
  18. using MongoDB.Driver.Core.Misc;
  19. namespace MongoDB.Driver.GridFS
  20. {
  21. /// <summary>
  22. /// Represents options for a GridFS upload operation.
  23. /// </summary>
  24. public class GridFSUploadOptions
  25. {
  26. // fields
  27. private IEnumerable<string> _aliases;
  28. private int? _batchSize;
  29. private int? _chunkSizeBytes;
  30. private string _contentType;
  31. private bool _disableMD5 = false;
  32. private BsonDocument _metadata;
  33. // properties
  34. /// <summary>
  35. /// Gets or sets the aliases.
  36. /// </summary>
  37. /// <value>
  38. /// The aliases.
  39. /// </value>
  40. [Obsolete("Place aliases inside metadata instead.")]
  41. public IEnumerable<string> Aliases
  42. {
  43. get { return _aliases; }
  44. set { _aliases = value; }
  45. }
  46. /// <summary>
  47. /// Gets or sets the batch size.
  48. /// </summary>
  49. /// <value>
  50. /// The batch size.
  51. /// </value>
  52. public int? BatchSize
  53. {
  54. get { return _batchSize; }
  55. set
  56. {
  57. _batchSize = Ensure.IsNullOrGreaterThanZero(value, nameof(value));
  58. }
  59. }
  60. /// <summary>
  61. /// Gets or sets the chunk size in bytes.
  62. /// </summary>
  63. /// <value>
  64. /// The chunk size in bytes.
  65. /// </value>
  66. public int? ChunkSizeBytes
  67. {
  68. get { return _chunkSizeBytes; }
  69. set { _chunkSizeBytes = Ensure.IsNullOrGreaterThanZero(value, nameof(value)); }
  70. }
  71. /// <summary>
  72. /// Gets or sets the type of the content.
  73. /// </summary>
  74. /// <value>
  75. /// The type of the content.
  76. /// </value>
  77. [Obsolete("Place contentType inside metadata instead.")]
  78. public string ContentType
  79. {
  80. get { return _contentType; }
  81. set { _contentType = Ensure.IsNullOrNotEmpty(value, nameof(value)); }
  82. }
  83. /// <summary>
  84. /// Gets or sets whether to disable MD5 checksum computation when uploading a GridFS file.
  85. /// </summary>
  86. /// <value>
  87. /// Whether or not MD5 checksum computation is disabled when uploading a GridFS file.
  88. /// </value>
  89. public bool DisableMD5
  90. {
  91. get { return _disableMD5; }
  92. set { _disableMD5 = value; }
  93. }
  94. /// <summary>
  95. /// Gets or sets the metadata.
  96. /// </summary>
  97. /// <value>
  98. /// The metadata.
  99. /// </value>
  100. public BsonDocument Metadata
  101. {
  102. get { return _metadata; }
  103. set { _metadata = value; }
  104. }
  105. }
  106. }