Registry / storage / multer-google-storage

multer-google-storage

JSON →
library1.3.0jsnpmunverified

A multer storage engine for Google Cloud Storage (GCS) that streams uploaded files directly to a GCS bucket. Version 1.3.0 is the current stable release, last updated in 2020 with no active development since. It supports both ES6 and CommonJS imports, ships TypeScript definitions, and provides automatic retry and custom filename generation. Unlike @google-cloud/multer or gcs-file-multer, this package offers a simpler API with default environment variable configuration (GCS_BUCKET, GCLOUD_PROJECT, GCS_KEYFILE) and supports custom content type functions. However, it relies on the deprecated @google-cloud/storage v2 API and has not been updated for newer Google authentication methods, making it unsuitable for new projects without careful configuration.

npm install multer-google-storage
INSTALL
IMPORT
SIG · MULTER-GOOGLE-STOR
M
multer-google-storage
storagejavascriptv1.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MulterGoogleCloudStorage
import MulterGoogleCloudStorage from 'multer-google-storage'
Default export is the storage engine class. Works with both ES6 and CommonJS.
storageEngine
const { storageEngine } = require('multer-google-storage')
const multerGoogleStorage = require('multer-google-storage').default
For CommonJS (ES5), use destructured require; default export is not available.
MulterGoogleCloudStorage type
import type { MulterGoogleCloudStorage } from 'multer-google-storage'
import { MulterGoogleCloudStorage } from 'multer-google-storage'
If only using the type, use import type to avoid runtime import errors in TypeScript.

Sets up an Express server with multer using MulterGoogleCloudStorage to upload a single file to GCS, with explicit configuration and custom filename.

import multer from 'multer'; import MulterGoogleCloudStorage from 'multer-google-storage'; import express from 'express'; const app = express(); const uploadHandler = multer({ storage: new MulterGoogleCloudStorage({ bucket: process.env.GCS_BUCKET ?? '', projectId: process.env.GCLOUD_PROJECT ?? '', keyFilename: process.env.GCS_KEYFILE ?? '', filename: (req, file, cb) => { cb(null, `${Date.now()}_${file.originalname}`); } }) }); app.post('/upload', uploadHandler.single('file'), (req, res) => { res.json({ file: req.file }); }); app.listen(3000);
Debug
Known issues
deprecatedPackage depends on @google-cloud/storage v2.x which is deprecated. Newer versions of the Google Cloud Storage client are incompatible.
fix
Consider using @google-cloud/multer or migrate to @google-cloud/storage v6+ with manual multer storage engine.
affects: >=1.0.0
gotchaThe default export in CommonJS is not available; you must use destructured require or call storageEngine().
fix
Use `const { storageEngine } = require('multer-google-storage');` instead of `const MulterGoogleCloudStorage = require('multer-google-storage').default;`
affects: >=1.0.0
gotchaEnvironment variables GCS_BUCKET, GCLOUD_PROJECT, and GCS_KEYFILE must be set if no configuration object is provided.
fix
Ensure these variables are set or pass explicit config to the constructor.
affects: >=1.0.0
deprecatedThe email configuration option is deprecated and may be removed in future versions.
fix
Do not rely on 'email' config; use keyFilename or default authentication instead.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The GCS_BUCKET environment variable is not set.
No bucket name provided either via config or environment variable.
fix
Set GCS_BUCKET environment variable or pass 'bucket' in config.
TypeError: multerGoogleStorage.default is not a constructor
Using CommonJS require with .default which is not exported.
fix
Use `const { storageEngine } = require('multer-google-storage');` and call `storageEngine()`.
Error: Cannot find module '@google-cloud/storage'
@google-cloud/storage v2+ is a required peer dependency not installed.
fix
Install it: `npm install @google-cloud/storage@2` (note: latest versions may break).
TypeError: MulterGoogleCloudStorage is not a constructor
Importing incorrectly in ES6 with named import instead of default.
fix
Use default import: `import MulterGoogleCloudStorage from 'multer-google-storage';`
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
multerrequiredRequired as peer dependency - this is a multer storage engine.
@google-cloud/storagerequiredRequired for GCS client, version 2.x only.
Agent activity
27 hits · last 30 days
node
24
Amazon
1
Resources
multer-google-storage — npm install multer-google-storage · libregistry