bucket.hpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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 <istream>
  16. #include <memory>
  17. #include <ostream>
  18. #include <bsoncxx/document/view_or_value.hpp>
  19. #include <bsoncxx/stdx/string_view.hpp>
  20. #include <bsoncxx/types/bson_value/view.hpp>
  21. #include <mongocxx/cursor.hpp>
  22. #include <mongocxx/gridfs/downloader.hpp>
  23. #include <mongocxx/gridfs/uploader.hpp>
  24. #include <mongocxx/options/find.hpp>
  25. #include <mongocxx/options/gridfs/bucket.hpp>
  26. #include <mongocxx/options/gridfs/upload.hpp>
  27. #include <mongocxx/result/gridfs/upload.hpp>
  28. #include <mongocxx/stdx.hpp>
  29. #include <mongocxx/config/prelude.hpp>
  30. namespace mongocxx {
  31. MONGOCXX_INLINE_NAMESPACE_BEGIN
  32. class database;
  33. namespace gridfs {
  34. ///
  35. /// Class representing a GridFS bucket.
  36. ///
  37. /// A GridFS bucket is used to store files that may be too large to store in a single document due
  38. /// to the 16 MB limit. The bucket comprises of two collections, `<bucketname>.files` and
  39. /// `<bucketname>.chunks.` A file written to a GridFS bucket will be serialized into zero or more
  40. /// chunk documents stored in the `<bucketname>.chunks` collection, and one document will be stored
  41. /// in the `<bucketname>.files` collection containing the information about the file. Users should
  42. /// not modify these collections directly.
  43. ///
  44. /// Example of how obtain the default GridFS bucket for a given database:
  45. /// @code
  46. /// mongocxx::client mongo_client{mongocxx::uri{}};
  47. /// auto gridfs_bucket = mongo_client["database"].gridfs_bucket();
  48. /// @endcode
  49. ///
  50. /// See also the method documentation for `mongocxx::database::gridfs_bucket()`.
  51. ///
  52. /// @see http://www.mongodb.org/display/DOCS/GridFS
  53. ///
  54. class MONGOCXX_API bucket {
  55. public:
  56. ///
  57. /// Default constructs a bucket object. The bucket is equivalent to the state of a moved from
  58. /// bucket. The only valid actions to take with a default constructed bucket are to assign to
  59. /// it, or destroy it.
  60. ///
  61. bucket() noexcept;
  62. ///
  63. /// Move constructs a bucket.
  64. ///
  65. bucket(bucket&&) noexcept;
  66. ///
  67. /// Move assigns a bucket.
  68. ///
  69. bucket& operator=(bucket&&) noexcept;
  70. ///
  71. /// Copy constructs a bucket.
  72. ///
  73. bucket(const bucket&);
  74. ///
  75. /// Copy assigns a bucket.
  76. ///
  77. bucket& operator=(const bucket&);
  78. ///
  79. /// Destroys a bucket.
  80. ///
  81. ~bucket();
  82. ///
  83. /// Returns true if the bucket is valid, meaning it was not default constructed or moved from.
  84. ///
  85. explicit operator bool() const noexcept;
  86. ///
  87. /// @{
  88. ///
  89. /// Opens a gridfs::uploader to create a new GridFS file. The id of the file will be
  90. /// automatically generated as an ObjectId.
  91. ///
  92. /// @param filename
  93. /// The name of the file to be uploaded. A bucket can contain multiple files with the same
  94. /// name.
  95. ///
  96. /// @param options
  97. /// Optional arguments; see options::gridfs::upload.
  98. ///
  99. /// @return
  100. /// A stream for writing to the GridFS file.
  101. ///
  102. /// @note
  103. /// If this GridFS bucket does not already exist in the database, it will be implicitly
  104. /// created and initialized with GridFS indexes.
  105. ///
  106. /// @throws mongocxx::logic_error if `options` are invalid.
  107. ///
  108. /// @throws mongocxx::query_exception
  109. /// if an error occurs when reading from the files collection for this bucket.
  110. ///
  111. /// @throws mongocxx::operation_exception if an error occurs when building GridFS indexes.
  112. ///
  113. uploader open_upload_stream(stdx::string_view filename,
  114. const options::gridfs::upload& options = {});
  115. ///
  116. /// Opens a gridfs::uploader to create a new GridFS file. The id of the file will be
  117. /// automatically generated as an ObjectId.
  118. ///
  119. /// @param session
  120. /// The mongocxx::client_session with which to perform the upload. The client session must
  121. /// remain valid for the lifetime of the uploader.
  122. ///
  123. /// @param filename
  124. /// The name of the file to be uploaded. A bucket can contain multiple files with the same
  125. /// name.
  126. ///
  127. /// @param options
  128. /// Optional arguments; see options::gridfs::upload.
  129. ///
  130. /// @return
  131. /// A stream for writing to the GridFS file.
  132. ///
  133. /// @note
  134. /// If this GridFS bucket does not already exist in the database, it will be implicitly
  135. /// created and initialized with GridFS indexes.
  136. ///
  137. /// @throws mongocxx::logic_error if `options` are invalid.
  138. ///
  139. /// @throws mongocxx::query_exception
  140. /// if an error occurs when reading from the files collection for this bucket.
  141. ///
  142. /// @throws mongocxx::operation_exception if an error occurs when building GridFS indexes.
  143. ///
  144. uploader open_upload_stream(const client_session& session,
  145. stdx::string_view filename,
  146. const options::gridfs::upload& options = {});
  147. ///
  148. /// @}
  149. ///
  150. ///
  151. /// @{
  152. ///
  153. /// Opens a gridfs::uploader to create a new GridFS file.
  154. ///
  155. /// @param id
  156. /// The unique id of the file being uploaded.
  157. ///
  158. /// @param filename
  159. /// The name of the file to be uploaded. A bucket can contain multiple files with the same
  160. /// name.
  161. ///
  162. /// @param options
  163. /// Optional arguments; see options::gridfs::upload.
  164. ///
  165. /// @return
  166. /// The gridfs::uploader to which the GridFS file should be written.
  167. ///
  168. /// @note
  169. /// If this GridFS bucket does not already exist in the database, it will be implicitly
  170. /// created and initialized with GridFS indexes.
  171. ///
  172. /// @throws mongocxx::logic_error if `options` are invalid.
  173. ///
  174. /// @throws mongocxx::query_exception
  175. /// if an error occurs when reading from the files collection for this bucket.
  176. ///
  177. /// @throws mongocxx::operation_exception if an error occurs when building GridFS indexes.
  178. ///
  179. uploader open_upload_stream_with_id(bsoncxx::types::bson_value::view id,
  180. stdx::string_view filename,
  181. const options::gridfs::upload& options = {});
  182. ///
  183. /// Opens a gridfs::uploader to create a new GridFS file.
  184. ///
  185. /// @param session
  186. /// The mongocxx::client_session with which to perform the upload. The client session must
  187. /// remain valid for the lifetime of the uploader.
  188. ///
  189. /// @param id
  190. /// The unique id of the file being uploaded.
  191. ///
  192. /// @param filename
  193. /// The name of the file to be uploaded. A bucket can contain multiple files with the same
  194. /// name.
  195. ///
  196. /// @param options
  197. /// Optional arguments; see options::gridfs::upload.
  198. ///
  199. /// @return
  200. /// The gridfs::uploader to which the GridFS file should be written.
  201. ///
  202. /// @note
  203. /// If this GridFS bucket does not already exist in the database, it will be implicitly
  204. /// created and initialized with GridFS indexes.
  205. ///
  206. /// @throws mongocxx::logic_error if `options` are invalid.
  207. ///
  208. /// @throws mongocxx::query_exception
  209. /// if an error occurs when reading from the files collection for this bucket.
  210. ///
  211. /// @throws mongocxx::operation_exception if an error occurs when building GridFS indexes.
  212. ///
  213. uploader open_upload_stream_with_id(const client_session& session,
  214. bsoncxx::types::bson_value::view id,
  215. stdx::string_view filename,
  216. const options::gridfs::upload& options = {});
  217. ///
  218. /// @}
  219. ///
  220. ///
  221. /// @{
  222. ///
  223. /// Creates a new GridFS file by uploading bytes from an input stream. The id of the file will
  224. /// be automatically generated as an ObjectId.
  225. ///
  226. /// @param filename
  227. /// The name of the file to be uploaded. A bucket can contain multiple files with the same
  228. /// name.
  229. ///
  230. /// @param source
  231. /// The non-null stream from which the GridFS file should be read. The exception mask on
  232. /// `source` will be cleared of `eofbit` and set for `failbit` and `badbit`.
  233. ///
  234. /// @param options
  235. /// Optional arguments; see options::gridfs::upload.
  236. ///
  237. /// @return
  238. /// The id of the uploaded file.
  239. ///
  240. /// @note
  241. /// If this GridFS bucket does not already exist in the database, it will be implicitly
  242. /// created and initialized with GridFS indexes.
  243. ///
  244. /// @throws mongocxx::logic_error if `options` are invalid.
  245. ///
  246. /// @throws mongocxx::bulk_write_exception
  247. /// if an error occurs when writing chunk data or file metadata to the database.
  248. ///
  249. /// @throws std::ios_base::failure
  250. /// if reading from `source` fails. Any exception thrown during the execution of
  251. /// `source::read()` will be re-thrown.
  252. ///
  253. /// @throws mongocxx::gridfs_exception
  254. /// if the uploader requires more than 2^31-1 chunks to store the file at the requested chunk
  255. /// size.
  256. ///
  257. /// @throws mongocxx::query_exception
  258. /// if an error occurs when reading from the files collection for this bucket.
  259. ///
  260. /// @throws mongocxx::operation_exception if an error occurs when building GridFS indexes.
  261. ///
  262. result::gridfs::upload upload_from_stream(stdx::string_view filename,
  263. std::istream* source,
  264. const options::gridfs::upload& options = {});
  265. ///
  266. /// Creates a new GridFS file by uploading bytes from an input stream. The id of the file will
  267. /// be automatically generated as an ObjectId.
  268. ///
  269. /// @param session
  270. /// The mongocxx::client_session with which to perform the upload.
  271. ///
  272. /// @param filename
  273. /// The name of the file to be uploaded. A bucket can contain multiple files with the same
  274. /// name.
  275. ///
  276. /// @param source
  277. /// The non-null stream from which the GridFS file should be read. The exception mask on
  278. /// `source` will be cleared of `eofbit` and set for `failbit` and `badbit`.
  279. ///
  280. /// @param options
  281. /// Optional arguments; see options::gridfs::upload.
  282. ///
  283. /// @return
  284. /// The id of the uploaded file.
  285. ///
  286. /// @note
  287. /// If this GridFS bucket does not already exist in the database, it will be implicitly
  288. /// created and initialized with GridFS indexes.
  289. ///
  290. /// @throws mongocxx::logic_error if `options` are invalid.
  291. ///
  292. /// @throws mongocxx::bulk_write_exception
  293. /// if an error occurs when writing chunk data or file metadata to the database.
  294. ///
  295. /// @throws std::ios_base::failure
  296. /// if reading from `source` fails. Any exception thrown during the execution of
  297. /// `source::read()` will be re-thrown.
  298. ///
  299. /// @throws mongocxx::gridfs_exception
  300. /// if the uploader requires more than 2^31-1 chunks to store the file at the requested chunk
  301. /// size.
  302. ///
  303. /// @throws mongocxx::query_exception
  304. /// if an error occurs when reading from the files collection for this bucket.
  305. ///
  306. /// @throws mongocxx::operation_exception if an error occurs when building GridFS indexes.
  307. ///
  308. result::gridfs::upload upload_from_stream(const client_session& session,
  309. stdx::string_view filename,
  310. std::istream* source,
  311. const options::gridfs::upload& options = {});
  312. ///
  313. /// @}
  314. ///
  315. ///
  316. /// @{
  317. ///
  318. /// Creates a new GridFS file with a user-supplied unique id by uploading bytes from an input
  319. /// stream.
  320. ///
  321. /// @param id
  322. /// A unique id for the file being uploaded.
  323. ///
  324. /// @param filename
  325. /// The name of the file to be uploaded. A bucket can contain multiple files with the same
  326. /// name.
  327. ///
  328. /// @param source
  329. /// The non-null stream from which the GridFS file should be read. The exception mask on
  330. /// `source` will be cleared of `eofbit` and set for `failbit` and `badbit`.
  331. ///
  332. /// @param options
  333. /// Optional arguments; see options::gridfs::upload.
  334. ///
  335. /// @note
  336. /// If this GridFS bucket does not already exist in the database, it will be implicitly
  337. /// created and initialized with GridFS indexes.
  338. ///
  339. /// @throws mongocxx::logic_error if `options` are invalid.
  340. ///
  341. /// @throws mongocxx::bulk_write_exception
  342. /// if an error occurs when writing chunk data or file metadata to the database.
  343. ///
  344. /// @throws std::ios_base::failure
  345. /// if reading from `source` fails. Any exception thrown during the execution of
  346. /// `source::read()` will be re-thrown.
  347. ///
  348. /// @throws mongocxx::gridfs_exception
  349. /// if the uploader requires more than 2^31-1 chunks to store the file at the requested chunk
  350. /// size.
  351. ///
  352. /// @throws mongocxx::query_exception
  353. /// if an error occurs when reading from the files collection for this bucket.
  354. ///
  355. /// @throws mongocxx::operation_exception if an error occurs when building GridFS indexes.
  356. ///
  357. void upload_from_stream_with_id(bsoncxx::types::bson_value::view id,
  358. stdx::string_view filename,
  359. std::istream* source,
  360. const options::gridfs::upload& options = {});
  361. ///
  362. /// Creates a new GridFS file with a user-supplied unique id by uploading bytes from an input
  363. /// stream.
  364. ///
  365. /// @param session
  366. /// The mongocxx::client_session with which to perform the upload.
  367. ///
  368. /// @param id
  369. /// A unique id for the file being uploaded.
  370. ///
  371. /// @param filename
  372. /// The name of the file to be uploaded. A bucket can contain multiple files with the same
  373. /// name.
  374. ///
  375. /// @param source
  376. /// The non-null stream from which the GridFS file should be read. The exception mask on
  377. /// `source` will be cleared of `eofbit` and set for `failbit` and `badbit`.
  378. ///
  379. /// @param options
  380. /// Optional arguments; see options::gridfs::upload.
  381. ///
  382. /// @note
  383. /// If this GridFS bucket does not already exist in the database, it will be implicitly
  384. /// created and initialized with GridFS indexes.
  385. ///
  386. /// @throws mongocxx::logic_error if `options` are invalid.
  387. ///
  388. /// @throws mongocxx::bulk_write_exception
  389. /// if an error occurs when writing chunk data or file metadata to the database.
  390. ///
  391. /// @throws std::ios_base::failure
  392. /// if reading from `source` fails. Any exception thrown during the execution of
  393. /// `source::read()` will be re-thrown.
  394. ///
  395. /// @throws mongocxx::gridfs_exception
  396. /// if the uploader requires more than 2^31-1 chunks to store the file at the requested chunk
  397. /// size.
  398. ///
  399. /// @throws mongocxx::query_exception
  400. /// if an error occurs when reading from the files collection for this bucket.
  401. ///
  402. /// @throws mongocxx::operation_exception if an error occurs when building GridFS indexes.
  403. ///
  404. void upload_from_stream_with_id(const client_session& session,
  405. bsoncxx::types::bson_value::view id,
  406. stdx::string_view filename,
  407. std::istream* source,
  408. const options::gridfs::upload& options = {});
  409. ///
  410. /// @}
  411. ///
  412. ///
  413. /// @{
  414. ///
  415. /// Opens a gridfs::downloader to read a GridFS file.
  416. ///
  417. /// @param id
  418. /// The id of the file to read.
  419. ///
  420. /// @return
  421. /// The gridfs::downloader from which the GridFS file should be read.
  422. ///
  423. /// @throws mongocxx::gridfs_exception
  424. /// if the requested file does not exist, or if the requested file has been corrupted.
  425. ///
  426. /// @throws mongocxx::query_exception
  427. /// if an error occurs when reading from the files collection for this bucket.
  428. ///
  429. downloader open_download_stream(bsoncxx::types::bson_value::view id);
  430. ///
  431. /// Opens a gridfs::downloader to read a GridFS file.
  432. ///
  433. /// @param session
  434. /// The mongocxx::client_session with which to perform the download. The client session must
  435. /// remain valid for the lifetime of the downloader.
  436. ///
  437. /// @param id
  438. /// The id of the file to read.
  439. ///
  440. /// @return
  441. /// The gridfs::downloader from which the GridFS file should be read.
  442. ///
  443. /// @throws mongocxx::gridfs_exception
  444. /// if the requested file does not exist, or if the requested file has been corrupted.
  445. ///
  446. /// @throws mongocxx::query_exception
  447. /// if an error occurs when reading from the files collection for this bucket.
  448. ///
  449. downloader open_download_stream(const client_session& session,
  450. bsoncxx::types::bson_value::view id);
  451. ///
  452. /// @}
  453. ///
  454. ///
  455. /// @{
  456. ///
  457. /// Downloads the contents of a stored GridFS file from the bucket and writes it to a stream.
  458. ///
  459. /// @param id
  460. /// The id of the file to read.
  461. ///
  462. /// @param destination
  463. /// The non-null stream to which the GridFS file should be written.
  464. ///
  465. /// @throws mongocxx::gridfs_exception
  466. /// if the requested file does not exist, or if the requested file has been corrupted.
  467. ///
  468. /// @throws mongocxx::query_exception
  469. /// if an error occurs when reading from the files or chunks collections for this bucket.
  470. ///
  471. /// @throws std::ios_base::failure
  472. /// if writing to `destination` fails. In addition, if `destination::exceptions()` is set for
  473. /// `badbit`, any exception thrown during execution of `destination::write()` will be
  474. /// re-thrown.
  475. ///
  476. void download_to_stream(bsoncxx::types::bson_value::view id, std::ostream* destination);
  477. ///
  478. /// Downloads the contents of a stored GridFS file from the bucket and writes it to a stream.
  479. ///
  480. /// @param session
  481. /// The mongocxx::client_session with which to perform the download.
  482. ///
  483. /// @param id
  484. /// The id of the file to read.
  485. ///
  486. /// @param destination
  487. /// The non-null stream to which the GridFS file should be written.
  488. ///
  489. /// @throws mongocxx::gridfs_exception
  490. /// if the requested file does not exist, or if the requested file has been corrupted.
  491. ///
  492. /// @throws mongocxx::query_exception
  493. /// if an error occurs when reading from the files or chunks collections for this bucket.
  494. ///
  495. /// @throws std::ios_base::failure
  496. /// if writing to `destination` fails. In addition, if `destination::exceptions()` is set for
  497. /// `badbit`, any exception thrown during execution of `destination::write()` will be
  498. /// re-thrown.
  499. ///
  500. void download_to_stream(const client_session& session,
  501. bsoncxx::types::bson_value::view id,
  502. std::ostream* destination);
  503. ///
  504. /// @}
  505. ///
  506. ///
  507. /// @{
  508. ///
  509. /// Deletes a GridFS file from the bucket.
  510. ///
  511. /// @param id
  512. /// The id of the file to be deleted.
  513. ///
  514. /// @throws mongocxx::gridfs_exception if the requested file does not exist.
  515. ///
  516. /// @throws mongocxx::bulk_write_exception
  517. /// if an error occurs when removing file data or chunk data from the database.
  518. ///
  519. void delete_file(bsoncxx::types::bson_value::view id);
  520. ///
  521. /// Deletes a GridFS file from the bucket.
  522. ///
  523. /// @param session
  524. /// The mongocxx::client_session with which to perform the delete.
  525. ///
  526. /// @param id
  527. /// The id of the file to be deleted.
  528. ///
  529. /// @throws mongocxx::gridfs_exception if the requested file does not exist.
  530. ///
  531. /// @throws mongocxx::bulk_write_exception
  532. /// if an error occurs when removing file data or chunk data from the database.
  533. ///
  534. void delete_file(const client_session& session, bsoncxx::types::bson_value::view id);
  535. ///
  536. /// @}
  537. ///
  538. ///
  539. /// @{
  540. ///
  541. /// Finds the documents in the files collection of the bucket which match the provided filter.
  542. ///
  543. /// @param filter
  544. /// Document view representing a document that should match the query.
  545. ///
  546. /// @param options
  547. /// Optional arguments; see options::find.
  548. ///
  549. /// @return
  550. /// A mongocxx::cursor with the results. If the query fails, the cursor throws
  551. /// mongocxx::query_exception when the returned cursor is iterated.
  552. ///
  553. /// @throws mongocxx::logic_error if the options are invalid, or if the unsupported option
  554. /// modifiers "$query" or "$explain" are used.
  555. ///
  556. /// @see mongocxx::collection::find.
  557. ///
  558. cursor find(bsoncxx::document::view_or_value filter, const options::find& options = {});
  559. ///
  560. /// Finds the documents in the files collection of the bucket which match the provided filter.
  561. ///
  562. /// @param session
  563. /// The mongocxx::client_session with which to perform the query. The client session must
  564. /// remain valid for the lifetime of the cursor.
  565. ///
  566. /// @param filter
  567. /// Document view representing a document that should match the query.
  568. ///
  569. /// @param options
  570. /// Optional arguments; see options::find.
  571. ///
  572. /// @return
  573. /// A mongocxx::cursor with the results. If the query fails, the cursor throws
  574. /// mongocxx::query_exception when the returned cursor is iterated.
  575. ///
  576. /// @throws mongocxx::logic_error if the options are invalid, or if the unsupported option
  577. /// modifiers "$query" or "$explain" are used.
  578. ///
  579. /// @see mongocxx::collection::find.
  580. ///
  581. cursor find(const client_session& session,
  582. bsoncxx::document::view_or_value filter,
  583. const options::find& options = {});
  584. ///
  585. /// @}
  586. ///
  587. ///
  588. /// Gets the name of the GridFS bucket.
  589. ///
  590. /// @return
  591. /// The name of the GridFS bucket.
  592. ///
  593. stdx::string_view bucket_name() const;
  594. private:
  595. friend class mongocxx::database;
  596. // Constructs a new GridFS bucket. Throws if options are invalid.
  597. MONGOCXX_PRIVATE bucket(const database& db, const options::gridfs::bucket& options);
  598. MONGOCXX_PRIVATE void create_indexes_if_nonexistent(const client_session* session);
  599. MONGOCXX_PRIVATE uploader _open_upload_stream_with_id(const client_session* session,
  600. bsoncxx::types::bson_value::view id,
  601. stdx::string_view filename,
  602. const options::gridfs::upload& options);
  603. MONGOCXX_PRIVATE void _upload_from_stream_with_id(const client_session* session,
  604. bsoncxx::types::bson_value::view id,
  605. stdx::string_view filename,
  606. std::istream* source,
  607. const options::gridfs::upload& options);
  608. MONGOCXX_PRIVATE downloader _open_download_stream(const client_session* session,
  609. bsoncxx::types::bson_value::view id);
  610. MONGOCXX_PRIVATE void _download_to_stream(const client_session* session,
  611. bsoncxx::types::bson_value::view id,
  612. std::ostream* destination);
  613. MONGOCXX_PRIVATE void _delete_file(const client_session* session,
  614. bsoncxx::types::bson_value::view id);
  615. class MONGOCXX_PRIVATE impl;
  616. MONGOCXX_PRIVATE impl& _get_impl();
  617. MONGOCXX_PRIVATE const impl& _get_impl() const;
  618. std::unique_ptr<impl> _impl;
  619. };
  620. } // namespace gridfs
  621. MONGOCXX_INLINE_NAMESPACE_END
  622. } // namespace mongocxx
  623. #include <mongocxx/config/postlude.hpp>