Hosting a file system in production?

by boogie man   Last Updated October 19, 2019 22:05 PM

Sorry if this is broad. But I'm confused on how to scale a file system.

I'm currently working on the server side of a webapp with Node(Express)js, its file system module, and mongoDB.

I'm storing images locally right now but don't understand where these would be stored in production. Are there dedicated cloud file servers that i could point to? Would whatever hosting platform i choose provide there own storage?

Or is storing the image in mongoDB my best bet over a file system?

Here's the code that's storing images locally in the project currently

const storageEngine = multer.diskStorage({
    destination: 'mylocalproject/data/images',
    filename(req, file, cb) {
        cb(null, Date.now() + file.fieldname + '-' + path.extname(file.originalname));
    }
})
const upload = multer({
    storage: storageEngine,
    limits: { fileSize:20000000 }//,
    // fileFilter: function(req, file, callback){
    //     validateFile(file, callback);
    // }
}).single('');

router.post('/uploadphoto', isLoggedIn, (req, res, next) => {

    upload(req, res, (err) => {
        if (err) {
            res.send(err);
        } else {
            return res.json(req.file);
        }
    });

});


Related Questions


Updated April 02, 2016 08:02 AM

Updated July 25, 2016 08:02 AM

Updated April 13, 2017 13:05 PM