Search
 
SCRIPT & CODE EXAMPLE
 

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);
  }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: Odoo13 How to open a JSON file and read it Avatar arian_shariat@comp.iust.ac.ir 23 February 2021 odoo 
Javascript :: useevent hook in react18 
Javascript :: how to focus icon of active screen react native 
Javascript :: connect vite with node js 
Javascript :: how to rotate camera around three JS object 
Javascript :: remove disabled js 
Javascript :: iso string to timestamp javascript 
Javascript :: Javascript case insensitive string comparison 
Javascript :: create a link javascript 
Javascript :: socket io https 
Javascript :: js add click listener 
Javascript :: javascript close current tab 
Javascript :: codewars js Get the Middle Character 
Javascript :: typeof date javascript 
Javascript :: @react-navigation/native unmount inactive 
Javascript :: js get website short name 
Javascript :: react native google play this device does not support 
Javascript :: how to delay execution in nodejs 
Javascript :: mousemove jquery 
Javascript :: localstorage setitem javascript 
Javascript :: javascript format number 
Javascript :: how 2 subtract 2 dates using moment.js 
Javascript :: js find node number in div 
Javascript :: js replace all number 
Javascript :: js wait 5 second 
Javascript :: array chunk javascript 
Javascript :: discord javascript how to create a role 
Javascript :: top-level code javascript 
Javascript :: tooltip.js cdn 
Javascript :: how to hide javascript element by class 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =