Registry / storage / multer-storage

multer-storage

JSON →
library0.4.1jsnpmunverified

A storage engine for Multer (Express middleware) that uploads files directly to Google Cloud Storage. Version 0.4.1 is the latest stable release. The package wraps the @google-cloud/storage client and provides configurable file path, metadata, and ACL settings. It is inspired by multer-s3 but focused on GCS. Uses callbacks for filepath and metadata generation. Currently in early development (WIP) with limited documentation and breaking changes likely in future versions. Release cadence is irregular.

npm install multer-storage
INSTALL
IMPORT
SIG · MULTER-STORAGE
M
multer-storage
storagejavascriptv0.4.1
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.

default
const MulterGCS = require('multer-storage')
import MulterGCS from 'multer-storage'
Package uses CommonJS; ESM import may not work. Default export is the factory function.
default
import MulterGCS from 'multer-storage' (if using ESM with bundler)
const { MulterGCS } = require('multer-storage')
Named destructuring fails because the module exports a single function directly, not an object.
default
const multer = require('multer'); const MulterGCS = require('multer-storage')
require('multer-storage')({...}) // Works but misleads on export
The default export is a function, so it can be called immediately, but for clarity define a variable.

Sets up an Express server that accepts file uploads and stores them in Google Cloud Storage using multer-storage.

const express = require('express'); const multer = require('multer'); const MulterGCS = require('multer-storage'); const app = express(); const upload = multer({ storage: MulterGCS({ projectId: process.env.GCLOUD_PROJECT_ID ?? '', keyFilename: process.env.GCLOUD_KEYFILE ?? '', bucket: process.env.GCLOUD_BUCKET ?? 'my-bucket', metadata: (req, file, cb) => cb(null, { contentType: file.mimetype }), filepath: (req, file, cb) => cb(null, Date.now() + '-' + file.originalname), acl: 'publicRead' }) }); app.post('/upload', upload.single('file'), (req, res) => { res.send(`Uploaded to: ${req.file.path}`); }); app.listen(3000);
Debug
Known issues
gotchaThe package is a work-in-progress (WIP); API may change without notice.
fix
Pin to a specific version and monitor updates.
affects: >=0.0.0
breakingACL parameter 'public-read' (kebab-case) in previous examples should be camelCase 'publicRead' in newer versions? Check documentation.
fix
Consult the source code or README for correct ACL format.
affects: >=0.4.0
deprecatedUsing 'keyFilename' is deprecated in favor of 'keyFile' in newer @google-cloud/storage.
fix
Use 'keyFile' instead.
affects: >=0.4.0
gotchaThe 'filepath' callback must return a path relative to the bucket root, not an absolute path.
fix
Return a relative path like 'uploads/file.pdf'.
affects: >=0.0.0
Errors
Common errors & fixes
Error: The bucket property must be provided
Missing or undefined 'bucket' option when calling MulterGCS().
fix
Ensure you pass a 'bucket' string in the configuration object.
TypeError: MulterGCS is not a function
Trying to use a named import (e.g., import { MulterGCS } from 'multer-storage') when the module exports a function as default.
fix
Use default import: const MulterGCS = require('multer-storage').
Error: No such file or directory, open '/path/to/keyfile.json'
The 'keyFilename' path provided does not exist or is incorrect.
fix
Provide an absolute path to a valid service account key JSON file.
Error: Could not load the default credentials
No Google Cloud credentials configured (e.g., missing GOOGLE_APPLICATION_CREDENTIALS environment variable or keyFilename).
fix
Set the GOOGLE_APPLICATION_CREDENTIALS env var or provide 'keyFilename' in the configuration.
Upgrade
Version history
0.4.1latest on npm
Audit
Dependencies
@google-cloud/storagerequiredRequired for interacting with Google Cloud Storage API.
multerrequiredPeer dependency; this package provides a storage engine for Multer.
Agent activity
30 hits · last 30 days
node
28
Amazon
1
OpenAI (training)
1
Resources
multer-storage — npm install multer-storage · libregistry