How I upload a video to aws s3 at the same time create a thumbnail for nodejs and mongodb

715 Views Asked by At

I upload videos and images using this code it was succesfull.

aws.config.update({
  region: process.env.AWS_BUCKET_REGION,
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_KEY,
});

const BUCKET = process.env.AWS_BUCKET_NAME;
const s3 = new aws.S3();

// Multer config
module.exports = multer({
  storage: multerS3({
    bucket: BUCKET,
    s3: s3,
    contentType: multerS3.AUTO_CONTENT_TYPE,
    acl: "public-read",

    key: function (req, file, cb) {
      cb(null, Date.now() + file.originalname); //use Date.now() for unique file keys
    },
  }),
});

and this code

  const file =req.file
  console.log(file)
 
    
    let user = new Image({
      name: req.body.name,
      thumbnail:req.file.location,
     
    });

now I want to upload my video and then the video screenshot is saved bucket

0

There are 0 best solutions below