Multer超级缓慢上传在收到图像的邮政请求后

发布于 2025-01-28 18:36:48 字数 722 浏览 3 评论 0原文

您好,我在A(ReactJS节点MySQL Express)堆栈中,我的网站有一个事件选项卡,管理员可以上传到IT事件。 每个事件都有封面照片,内部照片,标题和简短的文字。 我将整个表格发送到单个帖子请求(很好吗?

var fileUpload = multer({ storage:storage,
limits:{fileSize:150*1024*1024}
})
const multipleUpload = fileUpload.fields([{ name: 'coverPhoto', maxCount: 1 }, { name: 'innerPhotos', maxCount: 30 }])
const storage = multer.diskStorage({
  destination: (req, files, cb) => {
    cb(null, '../client/build/imgs/events')
  },
  filename: (req, files, cb) => {

    cb(null, files.originalname)

  }
})

因此, 花了很长时间才知道该格式是WebP,并且照片的尺寸很小。

知道为什么要花这么长时间? 我试图转移到强大的方法,但我无法弄清楚如何检索其中有多个文件的多个输入字段(我只成功发送了一个输入而不是多个输入),

谢谢

Hello I'm on a (ReactJs Node Mysql Express) stack, my website has an events tab which the admin could upload to it events.
Each event has a cover photo, inner photos, Title, and a brief text.
So I send this whole form in a single post request (is it good?)

var fileUpload = multer({ storage:storage,
limits:{fileSize:150*1024*1024}
})
const multipleUpload = fileUpload.fields([{ name: 'coverPhoto', maxCount: 1 }, { name: 'innerPhotos', maxCount: 30 }])
const storage = multer.diskStorage({
  destination: (req, files, cb) => {
    cb(null, '../client/build/imgs/events')
  },
  filename: (req, files, cb) => {

    cb(null, files.originalname)

  }
})

The server does recieve the request perfectly but after multer receives the photos it takes so long to move them to the fs and the reverse proxy would send a 524 error that it took so long knowing that the format is webp and the photos are so small in size.

Any idea why is it taking so long?
I tried to move to formidable but I couldn't figure how to retrieve multiple input fields with multiple files in it ( I only succeeded in sending one input not multiple inputs)

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文