Skip to content

Instantly share code, notes, and snippets.

@Rowadz
Last active July 28, 2019 21:25
Show Gist options
  • Save Rowadz/4c6e78c7c3ea672780f76d823482dd86 to your computer and use it in GitHub Desktop.
Save Rowadz/4c6e78c7c3ea672780f76d823482dd86 to your computer and use it in GitHub Desktop.
const myUpload = require('./my-upload');
const {
authenticate
} = require('@feathersjs/authentication').express;
const multer = require('multer');
const storage = multer.diskStorage({
destination: (req, file, cb) => cb(null, 'public/uploads'),
filename: (req, file, cb) => cb(null, `${Date.now()}-${file.originalname}`)
});
const upload = multer({
storage,
limits: {
fieldSize: 1e+8, // Max field value size in bytes, here it's 100MB
fileSize: 1e+7 // The max file size in bytes, here it's 10MB
// files: the number of files
// READ MORE https://www.npmjs.com/package/multer#limits
}
});
// eslint-disable-next-line no-unused-vars
module.exports = function (app) {
app.use('/media-upload', authenticate('jwt'), upload.array('files'), myUpload(app));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment