MongoDB C++ Driver  mongocxx-3.4.0
Public Member Functions | List of all members
mongocxx::gridfs::uploader Class Reference

Class used to upload a GridFS file. More...

#include <uploader.hpp>

Public Member Functions

 uploader () noexcept
 Default constructs an uploader object. More...
 
 uploader (uploader &&) noexcept
 Move constructs an uploader.
 
uploaderoperator= (uploader &&) noexcept
 Move assigns an uploader.
 
 ~uploader ()
 Destroys an uploader.
 
 operator bool () const noexcept
 Returns true if the uploader is valid, meaning it was not default constructed or moved from.
 
void write (const std::uint8_t *bytes, std::size_t length)
 Writes a specified number of bytes to a GridFS file. More...
 
result::gridfs::upload close ()
 Closes the uploader stream. More...
 
void abort ()
 Aborts uploading the file. More...
 
std::int32_t chunk_size () const
 Gets the chunk size of the file being uploaded. More...
 

Detailed Description

Class used to upload a GridFS file.

Constructor & Destructor Documentation

◆ uploader()

mongocxx::gridfs::uploader::uploader ( )
noexcept

Default constructs an uploader object.

The uploader is equivalent to the state of a moved from uploader. The only valid actions to take with a default constructed uploader are to assign to it, or destroy it.

Member Function Documentation

◆ abort()

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

Aborts uploading the file.

Exceptions
mongocxx::logic_errorif the upload stream was already closed.
mongocxx::bulk_write_exceptionif an error occurs when removing chunk data from the database.

◆ chunk_size()

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

Gets the chunk size of the file being uploaded.

Returns
The chunk size in bytes.

◆ close()

result::gridfs::upload mongocxx::gridfs::uploader::close ( )

Closes the uploader stream.

Exceptions
mongocxx::logic_errorif the upload stream was already closed.
mongocxx::bulk_write_exceptionif an error occurs when writing chunk data or file metadata to the database.
mongocxx::gridfs_exceptionif the uploader requires more than 2^31-1 chunks to store the file at the requested chunk size.

◆ write()

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

Writes a specified number of bytes to a GridFS file.

Parameters
bytesA pointer to the bytes to write.
lengthThe number of bytes to write.
Exceptions
mongocxx::logic_errorif the upload stream was already closed.
mongocxx::bulk_write_exceptionif an error occurs when writing chunk data to the database.
mongocxx::gridfs_exceptionif the uploader requires more than 2^31-1 chunks to store the file at the requested chunk size.

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