TypeError:下一步不是multer包中的函数

时间:2019-01-19 15:06:49

标签: node.js firebase multer

我上载文件时碰巧遇到这种错误。 我已经使用multer软件包很长时间了,没有任何问题。

我恰巧在节点v6.11.4上使用Google云存储

c

onst {Storage} = require('@google-cloud/storage')
const multer = require('multer');
//configuring the google cloud storage.
 const storage = new Storage({
  projectId: functions.config().project.id
  //keyFilename: "<path to service accounts prviate key JSON>"
 })

 //const bucket = storage.bucket("<Firebase Storage Bucket URL");
  const bucket = storage.bucket(functions.config().bucket.url)
  //multer confguration.. middleware
  const upload = multer({
    storage: multer.memoryStorage(),
    limits:{
      fileSize: 5 * 1024 * 1024 // no larger than 5mb, you can change as needed.
    }
  })
exports.updateUserRole = functions.https.onRequest(upload.single('license'),(req,res) => {

I expect this file to be uploaded
Actual results
TypeError: next is not a function at multerMiddleware (/user_code/node_modules/multer/lib/make-middleware.js:18:41) at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:57:9) at /var/tmp/worker/worker.js:726:7 at /var/tmp/worker/worker.js:709:11

1 个答案:

答案 0 :(得分:0)