shouldTransform being skipped
See original GitHub issueconst s3 = new AWS.S3();
const maxSize = 5 * 1000 * 1000;
/* TODO Resize */
const multerOptions = {
storage: multerS3({
s3: s3,
bucket: process.env.AWS_BUCKET,
bucketPath: 'images',
acl: 'public-read',
limits: {
fileSize: maxSize,
files: 5,
fields: 5,
},
contentType: multerS3.AUTO_CONTENT_TYPE,
key: function(req, file, cb) {
const extension = file.mimetype.split('/')[1]; // gets the extension
const area = req.body.area;
fileName = `${area}${uuid.v4()}.${extension}`;
cb(null, fileName);
},
shouldTransform: function(req, file, cb) {
cb(null, /^image/i.test(file.mimetype));
},
transforms: [
{
id: 'original',
transform: function(req, file, cb) {
//Perform desired transformations
cb(
null,
sharp()
.resize(600, 600)
.max()
);
},
},
],
}),
fileFilter(req, file, next) {
const isPhoto = file.mimetype.startsWith('image/');
if (isPhoto) {
next(null, true); // null for error means it worked and it is fine to continue to next()
} else {
next({ message: 'Fotos: Tipo de arquivo não suportado!' }, false); // with error
}
},
};
exports.upload = multer(multerOptions).array('photos', 5);
This is my temp code, trying to have the resize to work. I tried many different codes but it doesn’t look like the transforms array is being loaded at all. Is there a way I can call sharp() earlier and have multer upload the resized images to s3 then?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
multers3 skipping shouldTransform - node.js - Stack Overflow
My issue is in my multerS3 options shouldTransform is being skipped hence not taking the transforms. Here is my entire file of upload...
Read more >multer-s3-transform - npm
Streaming multer storage engine for AWS S3. This project is mostly an integration piece for existing code samples from Multer's storage ...
Read more >Why You Should Transform to Summon Shenron! Dragon Ball ...
I always tell you to transform when summoning Shenron... I should follow that advice myself.This is gameplay footage for Dragon Ball the ...
Read more >How financial services boards should transform sustainable ...
Financial services boards are quickly realizing that narrow oversight of sustainable finance is no longer suitable.
Read more >10 reasons you should transform your career - Accenture
Select "Life at Accenture" on the registration form. Already registered? Sign in to manage your subscriptions. Let there be change.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have installed multer-s3-transform but shouldTransform is still being skipped? I have been trying to figure this out for a while now. Help?
o u gotta use this
npm install multer-s3-transform