Registry / storage / multer-cloud-storage

multer-cloud-storage

JSON →
library4.1.0jsnpmunverified

Multer storage engine for Google Cloud Storage. v4.1.0 is current stable release. This package is a fork of multer-google-storage that uses the latest Google Cloud API, supports additional configuration (destination, contentType), and reduces module footprint. It ships TypeScript types and is intended for use with Express and Multer. The package has a moderate release cadence with occasional updates.

npm install multer-cloud-storage
INSTALL
IMPORT
SIG · MULTER-CLOUD-STORA
M
multer-cloud-storage
storagejavascriptv4.1.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-cloud-storage'
import { MulterGoogleCloudStorage } from 'multer-cloud-storage'
Default export (ESM). Named import will fail. For CJS use require('multer-cloud-storage').
storageEngine
import multerGoogleStorage from 'multer-cloud-storage'; multerGoogleStorage.storageEngine()
import { storageEngine } from 'multer-cloud-storage'
For CJS access via require. ESM default export is MulterGoogleCloudStorage class, not storageEngine.

Sets up an Express server with Multer and multer-cloud-storage to handle single file uploads to GCS.

import multer from 'multer'; import express from 'express'; import MulterGoogleCloudStorage from 'multer-cloud-storage'; const app = express(); const uploadHandler = multer({ storage: new MulterGoogleCloudStorage({ bucket: process.env.GCS_BUCKET ?? 'my-bucket', projectId: process.env.GCLOUD_PROJECT ?? 'my-project', keyFilename: process.env.GCS_KEYFILE ?? '/path/to/key.json', }), }); app.post('/upload', uploadHandler.single('file'), (req, res) => { console.log(req.file); res.json(req.file); }); app.listen(3000);
Debug
Known issues
gotchaConstructor expects an options object, not a config function. Passing no arguments reads from env vars.
fix
Pass a configuration object with bucket, projectId, etc. or set environment variables.
affects: >=4.0.0
deprecatedThe storageEngine() method is deprecated in favor of the MulterGoogleCloudStorage class.
fix
Use new MulterGoogleCloudStorage(options) directly.
affects: >=4.0.0
gotchaDefault import is MulterGoogleCloudStorage, not MulterGoogleCloudStorage as a named export.
fix
Use import MulterGoogleCloudStorage from 'multer-cloud-storage' (default import).
affects: >=4.0.0
Errors
Common errors & fixes
TypeError: multerGoogleStorage is not a constructor
Using ES6 import with default import incorrectly (e.g., with curly braces).
fix
Change to import MulterGoogleCloudStorage from 'multer-cloud-storage'.
Error: The environment variable GCS_BUCKET is not set.
No bucket provided via options or environment variables.
fix
Set GCS_BUCKET env variable or pass bucket in options object.
Cannot find module 'multer-cloud-storage'
Package not installed or path issue.
fix
Run npm install multer-cloud-storage.
Upgrade
Version history
4.1.0latest on npm
Audit
Dependencies
multerrequiredRequired as peer dependency for storage engine integration
@google-cloud/storagerequiredRequired for interacting with Google Cloud Storage
Agent activity
17 hits · last 30 days
node
16
Amazon
1
Resources
multer-cloud-storage — npm install multer-cloud-storage · libregistry