Registry / storage / multer-s3-transform

multer-s3-transform

JSON →
library2.10.3jsnpmunverified

multer-s3-transform v2.10.3 is a streaming multer storage engine for AWS S3, extended from multer-s3 with support for file transforms before upload. It avoids buffering entire files to disk by streaming multipart uploads directly to S3. Releases are irregular; it is a maintained fork of the original multer-s3. Key differentiators include transform support and ongoing updates.

npm install multer-s3-transform
INSTALL
IMPORT
SIG · MULTER-S3-TRANSFOR
M
multer-s3-transform
storagejavascriptv2.10.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.

multerS3
import multerS3 from 'multer-s3-transform'
const multerS3 = require('multer-s3-transform')
Default export only; available in ESM and CJS.
multerS3
const multerS3 = require('multer-s3-transform')
CJS require works for v2.10.3.
S3Storage
import { S3Storage } from 'multer-s3-transform'
const { S3Storage } = require('multer-s3-transform')
Not exported; only default export exists.

Sets up Express server with multer-s3-transform for file uploads to S3, including transform support.

const express = require('express'); const multer = require('multer'); const { S3Client } = require('@aws-sdk/client-s3'); const multerS3 = require('multer-s3-transform'); const app = express(); const s3 = new S3Client({ region: 'us-east-1', credentials: { accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '', secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? '' } }); const upload = multer({ storage: multerS3({ s3: s3, bucket: 'my-bucket', acl: 'public-read', metadata: (req, file, cb) => { cb(null, { fieldName: file.fieldname }); }, key: (req, file, cb) => { cb(null, Date.now().toString() + '-' + file.originalname); }, shouldTransform: (req, file, cb) => { cb(null, true); }, transforms: [ { id: 'resize', key: (req, file, cb) => { cb(null, 'resized-' + file.originalname); }, transform: (req, file, cb) => { cb(null, file.stream, file.mimetype); } } ] }) }); app.post('/upload', upload.array('photos', 3), (req, res) => { res.send('Uploaded ' + req.files.length + ' files'); }); app.listen(3000);
Debug
Known issues
gotchaUsing `@aws-sdk/client-s3` (v3) requires instantiating S3Client, not `new AWS.S3()`.
fix
Use S3Client from @aws-sdk/client-s3 and pass it as `s3` option.
affects: >=2.0.0
gotchaDO NOT pass the entire multerS3 object as `storage` without calling `multerS3(...)`.
fix
Call `multerS3({s3: ..., bucket: ...})` and pass the returned object to `multer({storage: ...})`.
affects: *
gotchaWhen using transforms, you must set `shouldTransform` callback; otherwise transforms are ignored.
fix
Implement `shouldTransform: function(req, file, cb) { cb(null, true); }`.
affects: >=2.0.0
deprecatedThe `acl` option as a static string is deprecated in favor of dynamic acl via callback.
fix
Use `acl` as a function (req, file, cb) => cb(null, 'public-read') for dynamic ACL.
affects: >=2.10.0
breakingv2.x drops support for Node.js < 12.0.0.
fix
Upgrade Node.js to 12+ or stick with v1.x.
affects: >=2.0.0 <3.0.0
Errors
Common errors & fixes
TypeError: multerS3 is not a function
Importing the package incorrectly (e.g., using ES named import when it's a default export).
fix
Use `const multerS3 = require('multer-s3-transform')` or `import multerS3 from 'multer-s3-transform'`.
InvalidStorageEngine: The `storage` property must be a valid storage engine object.
Passing `multerS3` (the constructor) instead of calling it (e.g., `storage: multerS3`).
fix
Call `multerS3({...})` and pass the result: `storage: multerS3({s3: ..., bucket: ...})`.
TypeError: s3.upload is not a function
Passing an S3 client from @aws-sdk/client-s3 v3 without wrapping in S3 class from aws-sdk v2.
fix
Use `const s3 = new S3Client(...)` from @aws-sdk/client-s3 and ensure the multerS3 options match. Alternatively, use aws-sdk v2 style.
Upgrade
Version history
2.10.3latest on npm
Audit
Dependencies
aws-sdkrequiredrequired for S3 client
Agent activity
16 hits · last 30 days
node
14
Amazon
1
Resources
multer-s3-transform — npm install multer-s3-transform · libregistry