首页 > 解决方案 > 使用 firebase 服务处理文件

问题描述

我正在尝试使用 firebase 服务器从请求中捕获文件,但由于某种原因我不能。我通常在我的节点项目中使用 multer 来处理它。下面我在一个简单的快速服务器上打印了两个请求,另一个用 firebase 打印。有没有我没有采用的特定配置?

...
const app = require('express')();
const bodyParser = require('body-parser');
const multer = require('multer');
...

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(multer().any());

// UPLOAD GC: POST
app.post('/upload', (req, res) => {
    console.log(req.files);
    res.send('ok'); 
})

Result console log >
i  functions: Beginning execution of "app"
>  [] 

简单快速服务器的结果控制台日志

Server running on port 3000!
[ { fieldname: 'avatar',
    originalname: 'file.png',
    encoding: '7bit',
    mimetype: 'image/png',
    buffer: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 02 00 00 00 02 00 08 06 00 00 00 f4 78 d4 fa 00 00 11 ca 7a 54 58 74 52 61 77 20 70 72 6f 66 69 ... >,
    size: 7858 } ]

标签: node.jsfilegoogle-cloud-functionsmulterfirebase-tools

解决方案


推荐阅读