如何在 Node.js/Sailsjs 的两个不同列上一次上传两张图片

How to upload Two images at a time on two different columns in Node.js/Sailsjs

错误:EMAXBUFFER:上游 (imagefile1) 在插入接收器之前超时。它是 等待 4500 毫秒后仍未使用。您可以通过更改 maxTimeToBuffer 配置此超时 option.Note 发生此错误的原因可能是较早的文件上传最终超时 在一个不相关的服务器错误之后。

我的代码:

        var uploaded = await sails.uploadOne(req.file('imagefile'));
        var oldPath = uploaded.fd;
        var filename = oldPath.split('\')[oldPath.split('\').length - 1];
        filename = filename.split('/')[filename.split('/').length - 1];
        var newPath = require('path').resolve(sails.config.appPath, 'assets/images/' + filename);
        fs.rename(oldPath, newPath, function (err) {
        })
        reportdata.IDPhoto = filename;

        var uploaded1 = await sails.uploadOne(req.file('imagefile1'));
        var oldPath = uploaded1.fd;
        var filename = oldPath.split('\')[oldPath.split('\').length - 1];
        filename = filename.split('/')[filename.split('/').length - 1];
        var newPath = require('path').resolve(sails.config.appPath, 'assets/images/' + filename);
        fs.rename(oldPath, newPath, function (err) {
        })
        reportdata.ProfilePhoto = filename;

我也尝试过使用 Skipper 来处理这段代码,但仍然出现 EMAXBUFFER 错误

        var reportdata = {
        city: req.body.city,
        pincode: req.body.pincode,
        WorkExperience: req.body.WorkExperience,
      };

        //// FIRST IMAGE UPLOAD FOR IDPhoto 

            var upload= req.file('imagefile').upload({
                dirname: '../../assets/images/'

            }, async function data(error, uploadedFiles1) {

                var oldPath = JSON.stringify(uploadedFiles1);

            var filename = oldPath.split('\')[oldPath.split('\').length - 1];
            var vals = filename.split('"')[0];

            reportdata.IDPhoto = vals;    //// IDPhoto Bind with reportdata which 
                                          //// is declare above

        })

       //////  SECOND IMAGE UPLOAD FOR ProfilePhoto ///////

            var uploade= req.file('imagefiles').upload({
                dirname: '../../assets/images/'

            }, async function data(error, uploadedFiles2) {

                var oldPath = JSON.stringify(uploadedFiles2);

            var filename = oldPath.split('\')[oldPath.split('\').length - 1];
            var vals = filename.split('"')[0];

          reportdata.ProfilePhoto = vals;//// ProfilePhoto Bind with reportdata which 
                                         //// is declare above

         var reportdata2 = await TABLENAME.create( reportdata);

            })  //// Both images will upload at a time and image URL will stores in 
                 ////Database Table in Two different Columns by CREATE Query