【问题标题】:Method to parse req with multipart content type in node.js在 node.js 中使用多部分内容类型解析 req 的方法
【发布时间】:2016-02-26 17:33:51
【问题描述】:

有没有办法从 http req 中提取文件而不保存在服务器上?

因为有一些解析器,如 Multer 和 Multiply ,但它们首先将文件保存在服务器位置。

我们可以像在 c# .Net 中那样解析 node.js 中的文件吗

Request.Files

【问题讨论】:

  • 您是否阅读了multer 文档,特别是关于memory storage 的部分?
  • 刚刚读到它有效,谢谢

标签: node.js http express


【解决方案1】:

在内存存储模式下使用 Multer 解决。

喜欢:-

var storage = multer.memoryStorage();

var upload = multer({ storage: storage });

这会将文件保存在缓冲区中 你可以像这样提取文件

app.post('/upload', upload.any(), function(req, res) {
    console.log(req.files);       
});

【讨论】:

    猜你喜欢
    • 2012-05-11
    • 2020-02-01
    • 1970-01-01
    • 2016-11-04
    • 1970-01-01
    • 2016-01-12
    • 2011-11-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多