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
Hello, I have tried to use multer-gridfs-storage and got the warning mentioned in the title. Could someone help?
upload.js
const multer = require('multer'); const { GridFsStorage } = require('multer-gridfs-storage'); const MONGO_URL = process.env.MONGO_URL; const DATABASE = process.env.DATANASE; const IMAGE_BUCKET = process.env.IMAGE_BUCKET; const storage = new GridFsStorage({ url: MONGO_URL + DATABASE, options: { useNewUrlParser: true, useUnifiedTopology: true }, // file is the function to control the file storage in the database file: (req, file) => { const match = ['image/png', 'image/jpeg']; if (match.indexOf(file.mimetype) === -1) { const filename = `${Date.now()}-J4I-${file.originalname}`; return filename; } return { bucketName: IMAGE_BUCKET, filename: `${Date.now()}-J4I-${file.originalname}`, }; }, }); // Multer module initializes middleware const uploadFiles = multer({ storage: storage }).single('file'); // util.promisify() makes the exported middleware object can be used with async/await const uploadFilesMiddleware = util.promisify(uploadFiles); module.exports = uploadFilesMiddleware;
.env
## MongoDB MONGO_URL='mongodb://localhost:27017/' DATABASE='J4I_files_db' IMAGE_BUCKET='photos'
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello, I have tried to use multer-gridfs-storage and got the warning mentioned in the title. Could someone help?
upload.js
.env
The text was updated successfully, but these errors were encountered: