Registry / storage / multer-azure-blob-storage

multer-azure-blob-storage

JSON →
library1.2.0jsnpmunverified

An ES5/6 & TypeScript-friendly Multer storage engine for Azure Blob Storage, currently at version 1.2.0. It allows direct upload of files from Express applications to Azure Blob Storage containers. Released with moderate cadence, key differentiators include strong TypeScript typings, support for custom blob name resolution via promises, and options for metadata and content settings. It integrates seamlessly with Multer and provides both CommonJS and ESM imports.

npm install multer-azure-blob-storage
INSTALL
IMPORT
SIG · MULTER-AZURE-BLOB-
M
multer-azure-blob-storage
storagejavascriptv1.2.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.

MulterAzureStorage
import { MulterAzureStorage } from 'multer-azure-blob-storage'
const MulterAzureStorage = require('multer-azure-blob-storage').MulterAzureStorage
ESM and CommonJS both supported; named export from package.
MASNameResolver
import { MASNameResolver } from 'multer-azure-blob-storage'
import { NameResolver } from 'multer-azure-blob-storage'
TypeScript type for custom name resolver function.
MASObjectResolver
import { MASObjectResolver } from 'multer-azure-blob-storage'
const { MASObjectResolver } = require('multer-azure-blob-storage')
TypeScript type for metadata/content settings resolver.

Sets up an Express endpoint that accepts a single file upload and stores it in Azure Blob Storage using MulterAzureStorage.

import * as multer from 'multer'; import { MulterAzureStorage } from 'multer-azure-blob-storage'; import express from 'express'; const app = express(); const azureStorage = new MulterAzureStorage({ connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING || '', accessKey: process.env.AZURE_STORAGE_ACCESS_KEY || '', accountName: process.env.AZURE_STORAGE_ACCOUNT_NAME || '', containerName: 'uploads', blobName: (req, file) => Promise.resolve(`${Date.now()}-${file.originalname}`), containerAccessLevel: 'blob', urlExpirationTime: 60 }); const upload = multer({ storage: azureStorage }); app.post('/upload', upload.single('file'), (req, res) => { res.json({ file: req.file }); }); app.listen(3000);
Debug
Known issues
breakingVersion 1.0.0 introduced a breaking change: the configuration options 'accessKey' and 'accountName' are now required when not using a connection string.
fix
Update to provide accessKey and accountName or a connection string.
affects: <1.0.0
deprecatedThe option 'containerAccessLevel' is deprecated in favor of 'containerAccessType' in newer versions of the Azure SDK.
fix
Use containerAccessType: 'blob' instead of containerAccessLevel: 'blob'.
affects: >=1.0.0
gotchaThe blobName option must return a Promise. If you return a string directly, the upload will fail silently.
fix
Ensure blobName function returns a Promise<string>.
affects: >=1.0.0
gotchaIf no urlExpirationTime is provided, the generated SAS URL will not expire (effectively infinite). This can be a security risk.
fix
Always set urlExpirationTime to a reasonable value (e.g., 60 minutes).
affects: >=1.0.0
breakingVersion 1.2.0 dropped support for Node.js 10 and below.
fix
Upgrade Node.js to version 12 or higher.
affects: <1.2.0
Errors
Common errors & fixes
Can't resolve 'multer-azure-blob-storage'
Package not installed or import path incorrect.
fix
Run 'npm install multer-azure-blob-storage' and ensure import path is correct.
TypeError: MulterAzureStorage is not a constructor
Using default import instead of named import.
fix
Use 'import { MulterAzureStorage } from 'multer-azure-blob-storage'' or 'const { MulterAzureStorage } = require('multer-azure-blob-storage')'
Error: Container 'containerName' does not exist
The specified Azure container does not exist.
fix
Create the container in Azure Portal or use the SDK to create it before upload.
The value for one of the HTTP headers is not in the correct format.
Misconfigured connection string or missing accessKey/accountName.
fix
Verify your connection string or provide accessKey and accountName.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
multerrequiredThis package is a storage engine for Multer; it must be used with Multer.
@azure/storage-blobrequiredThe package uses the Azure Storage Blob SDK to interact with Azure Blob Storage.
Agent activity
18 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
multer-azure-blob-storage — npm install multer-azure-blob-storage · libregistry