Siddharth2603

Untitled

May 17th, 2021
596
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. router.post(
  2.   "/feeddoc",
  3.   multer({ storage }).single("FeedDoc"),
  4.   passport.authenticate("founder", { session: false }),
  5.   async (req, res) => {
  6.     let myFile = req.file.originalname.split(".");
  7.     const fileType = myFile[myFile.length - 1];
  8.     const postsFields = {};
  9.     const params = {
  10.       Bucket: `testvcbay/Founder/${req.user.id}`,
  11.       Key: `${nanoid()}.${fileType}`,
  12.       Body: req.file.buffer,
  13.       ACL: "public-read",
  14.     };
  15.     s3.upload(params, (error, data) => {
  16.       if (error) {
  17.         res.status(500).send(error);
  18.       }
  19.  
  20.       postsFields.feedDoc = data.Location;
  21.           res.status(200).json({
  22.             feedDoc : data.Location
  23.         });
  24.     });
  25.   });
RAW Paste Data