Registry / storage / multer-aliyun-oss

multer-aliyun-oss

JSON →
library2.1.3jsnpmunverified

Multer storage engine for AliYun OSS (Object Storage Service). Current stable version 2.1.3. Allows uploading files directly to Alibaba Cloud OSS via multer middleware in Express-like Node.js apps. Provides configurable bucket, region, credentials, and optional destination/filename functions. No native TypeScript types; relies on @ali-oss SDK. Suitable for Node.js backend apps using Alibaba Cloud ecosystem.

npm install multer-aliyun-oss
INSTALL
IMPORT
SIG · MULTER-ALIYUN-OSS
M
multer-aliyun-oss
storagejavascriptv2.1.3
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 MAO = require('multer-aliyun-oss');
✗ import MAO from 'multer-aliyun-oss'; // ESM not supported
Package is CommonJS only, no ESM export. Use require().
default
✓ const upload = multer({ storage: MAO({...}) });
✗ const upload = multer({ storage: new MAO({...}) }); // MAO is not a constructor
MAO is a function that returns a storage engine object, not a class.
destination
✓ destination: (req, file, cb) => cb(null, 'uploads/')
✗ destination: '/uploads' // will be ignored; must use function or empty string
If set as string, it's used directly; but to mimic multer DiskStorage, use function.

Express server with single file upload to AliYun OSS using multer middleware.

const express = require('express'); const multer = require('multer'); const MAO = require('multer-aliyun-oss'); const app = express(); const upload = multer({ storage: MAO({ config: { region: process.env.OSS_REGION ?? '', accessKeyId: process.env.OSS_ACCESS_KEY_ID ?? '', accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET ?? '', bucket: process.env.OSS_BUCKET ?? '', }, destination: 'uploads', filename: (req, file, cb) => { cb(null, Date.now() + '-' + file.originalname); } }) }); app.post('/upload', upload.single('file'), (req, res) => { console.log(req.file); res.send('OK'); }); app.listen(3000);
Debug
Known issues
gotchaThe package expects config props 'region', 'accessKeyId', 'accessKeySecret', 'bucket' exactly; typos cause silent auth failures.
fix
Double-check property names and ensure environment variables are set correctly.
affects: >=1.0.0
gotchadestination option as function receives (req, file, callback) but does NOT provide file.mimetype etc. properties during callback. Use req/file as needed.
fix
Access file properties inside callback: cb(null, 'images/' + file.fieldname);
affects: >=1.0.0
deprecatedThe underlying @ali-oss SDK may change; this package may need updates for newer OSS API versions.
fix
Monitor @ali-oss upgrade notes and test compatibility.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'region' of undefined
config object is missing or misspelled properties.
fix
Ensure 'config' object contains region, accessKeyId, accessKeySecret, and bucket strings.
TypeError: MAO is not a constructor
Attempting to use 'new MAO()' instead of calling as a function.
fix
Use 'multers()' (no new).
Error: ENOENT: no such file or directory, open '...'
Incorrect destination path; this package tries to create a local temp file before uploading? Actually it streams directly, but this error may appear if the OS cannot handle streaming.
fix
Check destination path and ensure writable permissions. Use absolute path or empty destination to use root.
Upgrade
Version history
2.1.3latest on npm
Audit
Dependencies
@ali-ossrequiredRequired for interacting with AliYun OSS API
multerrequiredPeer dependency; the storage engine is used with multer
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
multer-aliyun-oss — npm install multer-aliyun-oss · libregistry