MongoDB C++ Driver 4.2.0
Loading...
Searching...
No Matches
mongocxx::v1::gridfs::uploader Class Reference

#include <mongocxx/v1/gridfs/uploader.hpp>

Description

Support for uploading files to a GridFS bucket.

See also
Attention
This feature is experimental! It is not ready for use!

Public Types

enum class  errc
 Errors codes which may be returned by mongocxx::v1::gridfs::uploader. More...

Public Member Functions

 uploader ()
 Default initialization.
 uploader (uploader &&other) noexcept
 Move constructor.
 uploader (uploader const &other)=delete
 This class is not copyable.
 ~uploader ()
 Destroy this object.
void abort ()
 Abort uploading this GridFS file.
std::int32_t chunk_size () const
 Return the chunk size (in bytes) of the associated GridFS file.
v1::gridfs::upload_result close ()
 Complete the upload of this GridFS file.
void flush ()
 Flush the internal buffer.
bool is_open () const
 Return true when the underlying GridFS file stream is open for writing.
 operator bool () const
 Return true when *this is NOT in an assign-or-destroy-only state and this->is_open() == true.
uploaderoperator= (uploader &&other) noexcept
 Move assignment.
uploaderoperator= (uploader const &other)=delete
 This class is not copyable.
void write (std::uint8_t const *data, std::size_t length)
 Write length bytes of the associated GridFS file.

Static Public Member Functions

static std::error_category const & error_category ()
 The error category for mongocxx::v1::gridfs::uploader::errc.

Friends

std::error_code make_error_code (errc v)
 Support implicit conversion to std::error_code.

Member Enumeration Documentation

◆ errc

Errors codes which may be returned by mongocxx::v1::gridfs::uploader.

Attention
This feature is experimental! It is not ready for use!
Enumerator
zero 

Zero.

is_closed 

The GridFS file upload stream is not open.

too_many_chunks 

The total number of chunks must be less than INT32_MAX.

Constructor & Destructor Documentation

◆ ~uploader()

mongocxx::v1::gridfs::uploader::~uploader ( )

Destroy this object.

Calls close(). Any exceptions are caught and ignored.

Note
When a server-side error is encountered, already-uploaded chunks are "orphaned" and no cleanup attempt is made.

◆ uploader() [1/3]

mongocxx::v1::gridfs::uploader::uploader ( uploader && other)
noexcept

Move constructor.

Postconditions:
  • other is in an assign-or-destroy-only state.

◆ uploader() [2/3]

mongocxx::v1::gridfs::uploader::uploader ( uploader const & other)
delete

This class is not copyable.

◆ uploader() [3/3]

mongocxx::v1::gridfs::uploader::uploader ( )

Default initialization.

Postconditions:
  • *this is in an assign-or-destroy-only state.

Member Function Documentation

◆ abort()

void mongocxx::v1::gridfs::uploader::abort ( )

Abort uploading this GridFS file.

Note
When a server-side error is encountered, already-uploaded chunks are "orphaned" and no cleanup attempt is made.
Postconditions:
  • All uploaded chunks for this GridFS file are deleted, unless a server-side error is encountered.
Exceptions
mongocxx::v1::exceptionwith mongocxx::v1::gridfs::uploader::errc::is_closed if the underlying GridFS download stream was already closed.
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.

◆ chunk_size()

std::int32_t mongocxx::v1::gridfs::uploader::chunk_size ( ) const

Return the chunk size (in bytes) of the associated GridFS file.

◆ close()

v1::gridfs::upload_result mongocxx::v1::gridfs::uploader::close ( )

Complete the upload of this GridFS file.

Note
When a server-side error is encountered, already-uploaded chunks are "orphaned" and no cleanup attempt is made.
Returns
The files collection document for the successfully uploaded GridFS file.
Exceptions
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.

◆ error_category()

std::error_category const & mongocxx::v1::gridfs::uploader::error_category ( )
static

The error category for mongocxx::v1::gridfs::uploader::errc.

Attention
This feature is experimental! It is not ready for use!

◆ flush()

void mongocxx::v1::gridfs::uploader::flush ( )

Flush the internal buffer.

Note
When a server-side error is encountered, already-uploaded chunks are "orphaned" and no cleanup attempt is made.
Exceptions
mongocxx::v1::exceptionwith mongocxx::v1::gridfs::uploader::errc::is_closed if the underlying GridFS download stream was already closed.
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.

◆ is_open()

bool mongocxx::v1::gridfs::uploader::is_open ( ) const

Return true when the underlying GridFS file stream is open for writing.

◆ operator bool()

mongocxx::v1::gridfs::uploader::operator bool ( ) const
explicit

Return true when *this is NOT in an assign-or-destroy-only state and this->is_open() == true.

◆ operator=() [1/2]

uploader & mongocxx::v1::gridfs::uploader::operator= ( uploader && other)
noexcept

Move assignment.

Postconditions:
  • other is in an assign-or-destroy-only state.

◆ operator=() [2/2]

uploader & mongocxx::v1::gridfs::uploader::operator= ( uploader const & other)
delete

This class is not copyable.

◆ write()

void mongocxx::v1::gridfs::uploader::write ( std::uint8_t const * data,
std::size_t length )

Write length bytes of the associated GridFS file.

An internal buffer is used to reduce the total number of collection write operations. Use flush() to manually flush the internal buffer.

Note
When a server-side error is encountered, already-uploaded chunks are "orphaned" and no cleanup attempt is made.
Preconditions:
  • data is not null.
  • The size of the storage region pointed to by data must be greater than or equal to length.
Exceptions
mongocxx::v1::exceptionwith mongocxx::v1::gridfs::uploader::errc::is_closed if the underlying GridFS download stream was already closed.
mongocxx::v1::exceptionwith mongocxx::v1::gridfs::uploader::errc::too_many_chunks if the total number of chunks would be greater than or equal to INT32_MAX.
mongocxx::v1::server_errorwhen a server-side error is encountered and a raw server error is available.
mongocxx::v1::exceptionfor all other runtime errors.

◆ make_error_code

std::error_code make_error_code ( errc v)
friend

Support implicit conversion to std::error_code.

Attention
This feature is experimental! It is not ready for use!

The documentation for this class was generated from the following file: