Skip to content
New issue

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

No error thrown if config object is passed in to multer without being wrapped in an object #55

Open
rmgreenstreet opened this issue Aug 3, 2024 · 0 comments

Comments

@rmgreenstreet
Copy link

rmgreenstreet commented Aug 3, 2024

In the readme it is implied, though not explicitly stated, that the config object needs to be passed into multer within another object, e.g. { storage: storage }

However if the config object is passed in without being wrapped in an object itself, nothing untoward happens until an attempt to upload an item to cloudinary is made, in which case no path, url, etc. are returned, and things get broken at that point.

// Config object in my /cloudinary/index.js
const storage = new CloudinaryStorage({
    cloudinary: cloudinary,
    params: {
      folder: 'DBName',
      allowedFormats: [
        "jpg",
        "jpeg",
        "png"
      ]
    }
  });

// Multer/cloudinary setup in my controller
const multer = require("multer");
const { storage } = require("../cloudinary")
const upload = multer(storage); // No error thrown if the config object is passed in without being in an object, itself

It would be nice to have a check to make sure that the proper format is passed in to the multer instance, and an error be thrown during compile if not. I had to get some sleep before I was able to nail down this issue!

I apologize if this is actually a plain multer issue, rather than a multer-storage-cloudinary issue. Let me know if I need to post there instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant