Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead

//add var
let gridFSBucket;
let gfs;
connection.once('open', () => {
  gfs = Grid(conn.db, mongoose.mongo);
  // add value to new var
  gridFSBucket = new mongoose.mongo.GridFSBucket(conn.db, {
    bucketName: 'user_images'
  });

  gfs = Grid(connection.db, mongoose.mongo);
  gfs.collection(image_bucket_name);

  if (file.contentType === 'image/jpeg' || file.contentType === 'image/png') {
    //now instead of const readstream = gfs.createReadStream(file.filename);
    //add this line
    const readStream = gridFSBucket.openDownloadStream(file._id);
    readSteam.pipe(res);
  }
});
 
PREVIOUS NEXT
Tagged: #GridStore #removed #future #Please #GridFSBucket
ADD COMMENT
Topic
Name
4+4 =