0

You can save the data received from a http.request post directly into GridFS to minimize memory usage? Can anyone give me an example, Note: the size of data are 10Mb+, im using Post to send and i can't do this

request.addListener('data', function (chunk) {
    data += chunk;
});

because I need to minimize memory usage. I need something like:

request.addListener('data', function (chunk) {
   db.append(chunk);
});
manell
  • 1
  • 1

1 Answers1

0

You have to first convert the received data to JSON format and then you can simply do:

var jsonStr = <your response data>;
db.posts.insert({ "data": jsonStr});
Shubhanshu Mishra
  • 6,210
  • 6
  • 21
  • 23