
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
A package to easily save filenames to MongoDB
Install mongofiles with npm
npm install mongofiles
Server: Node, Express
const Blog = require("../models/blog");
const mongofiles = require("mongofiles"); //importing mongofiles
exports.add = (req, res, next) => {
var {
images,
featuredimage
} = req.body;
//for more than one files, it return array of filenames
images = mongofiles.manyfile( req.files.images, "images", "filename" );
//for only one file it returns a string
featuredimage = mongofiles.onefile(req.files.featuredimage, featuredimage, "filename");
let newBlog = new Blog({
images,
featuredimage
});
newBlog.save((err, data) => {
if (err) {
return res.status(400).json({
error: err,
});
console.log(err);
} else {
res.json(data);
console.log(data);
}
});
};
//return a array of filenames
mongofiles.manyfiles(req.files.<name>, "name" , "Option", custom )
//return a string of single file
mongofiles.onefile(req.files.<name>, "name" , "Option", custom )
Select any for options Required Options are same for manyfiles and onefile
| Option | Type | Description |
|---|---|---|
original | string | Returns original filename |
filename | string | Returns filename uploaded with the name |
customfilename | string | Returns filename uploaded file with the custom string or number name |
customoriginalname | string | Returns original uploaded file with the custom string or number name |
Custom is only mandatory if you go for customfilename and customoriginalname
You can write string or number there or pass Date.now()
FAQs
A package to save files name into mongodb easily
The npm package mongofiles receives a total of 4 weekly downloads. As such, mongofiles popularity was classified as not popular.
We found that mongofiles demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.