0

I happen to be getting this kind of error when i upload the files. i have been using multer package for long time without any issues.

I happen to be using google cloud storage on node v6.11.4

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 Answers1

0

Formidable doesn't work with Cloud Functions, for the same reason that multer doesn't work. Use busboy instead. How to perform an HTTP file upload using express on Cloud Functions for Firebase (multer, busboy) So this question is somehow related to above issues in the links unless someone objects as per now...