I want to use the mongo-cxx-driver to upload files but can't find a way. Tried to use the gridfs feature of mongodb but couldn't integrate. Using current stable version mongodb-cxx-driver (3.1.1).
gridFs throws error when try to store file like this:
gfs.storeFile("filepath", "filename");
Error: store_file: /usr/include/boost/smart_ptr/scoped_ptr.hpp:99: T* boost::scoped_ptr::operator->() const [with T = mongo::AtomicWord]: Assertion `px != 0' failed. Aborted (core dumped)
Also if mongo client is initialized it provides segmentation fault error.
#include "mongo/client/dbclient.h"
#include <iostream>
#include <cstdlib>
using namespace std;
using namespace mongo;
int main(int argc, const char** argv) {
cout<<"good so far"<<endl;
client::GlobalInstance instance; //everytime producing segmentation fault
if (!instance.initialized()) {
std::cout << "failed to initialize the client driver: " << instance.status() << std::endl;
return EXIT_FAILURE;
}
else
{
std::cout << "Successfully initialized the client driver: " << instance.status() << std::endl;
}
return EXIT_SUCCESS;
}