如何在没有 lambda 函数的情况下在 nodejs 中同时存储我在 AWS 上上传的视频的缩略图?

How can I store thumbnails for videos I upload on AWS at the same time in nodejs without lambda function?

我正在使用 ffmpeg 创建缩略图。我已在 AWS 上成功为上传的视频创建缩略图。

上传 video/videos 我的流程如下:

有什么方法可以直接将 AWS S3 路径提供给 Thumbnail 函数的第二个参数吗?

const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(ffmpegPath);
var ffprobe = require('ffprobe-static');
ffmpeg.setFfprobePath(ffprobe.path);

...
 ffmpeg({ source: req.files[k].location })

 .on('filenames', (filenames) => {
     console.log("Created file name", filenames);
  })
  .on('end', () => {
  return res.status(200).json({ success: true, message: "Files uploaded successfully",   data: uploadedMedia })
  })
  .on('error', (err) => {
     console.log("Error", err);
  })
  .thumbnail({
    filename: 'thumbnail_' + req.files[k].key.split('.')[0],count: 1
    }, './uploads/thumbnails/<<HERE I WANT TO ADD S3 path');

此解决方案非常适合从视频制作缩略图并将其上传到 S3。

ffmpeg({ source: 'location of the file' })
.on('filenames', (filenames) => {
   // created an array of thumbnail files as I have multiple media upload
})
.on('end', () => {
   for (let i in arrayofthumbnailfiles) {
       const uploadFile = () => {
           filePath = 'path where I have stored my thumbnails before s3 upload'
           const params = {
              Bucket:// pass your bucket name
              Key: // pass your key name,
              Body: fs.createReadStream(filePath),
              ContentType: // media content i.e. png,
              ACL:// add ACL value here
           };
           // here I have uploaded thumbnails in s3
           s3.upload(params, function (s3Err, data) {
           if (s3Err) throw s3Err
           if (data) {
              // Unlink file - removed from local storage
           }
         });
       };
    uploadFile();
   }
  })
 .on('error', (err) => {
     console.log("Error", err);
  })
.thumbnail({filename: //set your filename here,count: 1}, 'localstorage path you want to save thumbnails temporary');