Have ideas to improve npm?Join in the discussion! »

    multer-gcloud

    0.2.3 • Public • Published

    multer-gcloud

    A storage module for connect gcloud with multer

    Install

        $ npm install --save multer-gcloud

    Config

    var multer_gcloud = require('multer-gcloud');
     
    var gcloud = require('@google-cloud/storage')({
      projectId: '<projectId>',
      keyFilename: '<google-cloud-service.json>'
    });
     
    var bucket = gcloud.bucket('<storageBucket>');
     
    const storage = multer_gcloud({
      storage_bucket: '<storageBucket>',
      bucket: bucket,
      metadata: function (req, file, cb) {
        cb(null, file.mimetype);
      },
      destination: function (req, file, cb) {
        cb(null, 'uploads');
      },
      filename: function (req, file, cb) {
        cb(null, + Date.now() + '.' + ext(file.originalname));
      }
    });
     
    const upload = multer({ storage: storage }).single('picture');

    Install

    npm i multer-gcloud

    DownloadsWeekly Downloads

    2

    Version

    0.2.3

    License

    MIT

    Last publish

    Collaborators

    • avatar