Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
How to upload files in MongoDB through mongocxx C++ driver?

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;
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

That looks like the legacy client, not the stable 3.1.1 version.

GridFS is not yet available for the stable client (initial priority was on essential CRUD features), but GridFS is under active development and will be available in the 3.2.0 release expected in the next couple months. If you want to keep an eye on progress, the relevant JIRA ticket is CXX-1130.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!