We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code that still allowed false file to be uploaded to cloudinary
const storage = new CloudinaryStorage({ cloudinary, params: async (req, file) => { return { folder: process.env.CLOUDINARY_FOLDER_NAME, allowedFormats: ['png','jpeg','jpg'], public_id: crypto.randomBytes(16).toString("hex"), }; }, }); const upload = multer({ storage: storage, limits: { fileSize: MAXFILESIZE }, fileFilter: (req, file, cb) => { if (!allowedFormats.includes(file.mimetype)) { cb(new UploadError("only jpeg/png/jpg images allowed!")); } cb(null, true); }, });
this still allowed file to be uploaded to cloudinary. so i had to throw an err in instantiation of CloudinaryStorage object to prevent that.
CloudinaryStorage
const allowedFormats = ["image/jpeg", "image/jpg", "image/png"]; const storage = new CloudinaryStorage({ cloudinary, params: async (req, file) => { if (!allowedFormats.includes(file.mimetype)) { throw new UploadError( `only files of mimetype ${allowedFormats.join(",")} are allowed` ); } return { folder: process.env.CLOUDINARY_FOLDER_NAME, public_id: crypto.randomBytes(16).toString("hex"), }; }, });
i think something to handle this situation should be added to this package for improvement
The text was updated successfully, but these errors were encountered:
No branches or pull requests
code that still allowed false file to be uploaded to cloudinary
this still allowed file to be uploaded to cloudinary. so i had to throw an err in instantiation of
CloudinaryStorage
object to prevent that.i think something to handle this situation should be added to this package for improvement
The text was updated successfully, but these errors were encountered: