Last active
July 28, 2019 21:25
-
-
Save Rowadz/4c6e78c7c3ea672780f76d823482dd86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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