upload.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2017 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. #pragma once
  15. #include <bsoncxx/document/view_or_value.hpp>
  16. #include <bsoncxx/stdx/optional.hpp>
  17. #include <mongocxx/stdx.hpp>
  18. #include <mongocxx/config/prelude.hpp>
  19. namespace mongocxx {
  20. MONGOCXX_INLINE_NAMESPACE_BEGIN
  21. namespace options {
  22. namespace gridfs {
  23. ///
  24. /// Class representing the optional arguments to a MongoDB GridFS upload operation.
  25. ///
  26. class MONGOCXX_API upload {
  27. public:
  28. ///
  29. /// Sets the chunk size of the GridFS file being uploaded. Defaults to the chunk size specified
  30. /// in options::gridfs::bucket.
  31. ///
  32. /// @param chunk_size_bytes
  33. /// The size of the chunks in bytes.
  34. ///
  35. /// @return
  36. /// A reference to the object on which this member function is being called. This facilitates
  37. /// method chaining.
  38. ///
  39. upload& chunk_size_bytes(std::int32_t chunk_size_bytes);
  40. ///
  41. /// Gets the chunk size of the GridFS file being uploaded.
  42. ///
  43. /// @return
  44. /// The chunk size of the GridFS file being uploaded in bytes.
  45. ///
  46. const stdx::optional<std::int32_t>& chunk_size_bytes() const;
  47. ///
  48. /// Sets the metadata field of the GridFS file being uploaded. A GridFS file can store arbitrary
  49. /// metadata in the form of a BSON document.
  50. ///
  51. /// @param metadata
  52. /// The metadata document for the GridFS file.
  53. ///
  54. /// @return
  55. /// A reference to the object on which this member function is being called. This facilitates
  56. /// method chaining.
  57. ///
  58. upload& metadata(bsoncxx::document::view_or_value metadata);
  59. ///
  60. /// Gets the metadata of the GridFS file being uploaded.
  61. ///
  62. /// @return
  63. /// The metadata document of the GridFS file.
  64. ///
  65. const stdx::optional<bsoncxx::document::view_or_value>& metadata() const;
  66. private:
  67. stdx::optional<std::int32_t> _chunk_size_bytes;
  68. stdx::optional<bsoncxx::document::view_or_value> _metadata;
  69. };
  70. } // namespace gridfs
  71. } // namespace options
  72. MONGOCXX_INLINE_NAMESPACE_END
  73. } // namespace mongocxx
  74. #include <mongocxx/config/postlude.hpp>