Commit c173cd2b authored by Vytor Calixto's avatar Vytor Calixto 👾
Browse files

Extensão do arquivo e provendo imagens

parent fdf5de54
......@@ -35,6 +35,7 @@ app.use('/v1/materias', materias)
app.use('/v1/professores', professores)
app.use('/v1/arquivos', arquivos)
app.use('/v1/oauth/token', oauth2.token)
app.use('/uploads', express.static('uploads'))
// catch 404 and forward to error handler
app.use(function(req, res, next){
......
......@@ -2,7 +2,19 @@ var express = require('express')
var passport = require('passport')
var router = express.Router()
var multer = require('multer')
var upload = multer({dest: 'uploads/'})
var crypto = require('crypto')
var path = require('path')
var storage = multer.diskStorage({
destination: function(req, file, cb) {
cb(null, 'uploads/')
},
filename: function(req, file, cb) {
crypto.pseudoRandomBytes(16, function(err, raw) {
cb(null, raw.toString('hex') + Date.now() + path.extname(file.originalname))
})
}
})
var upload = multer({storage: storage})
var fs = require('fs')
var libs = process.cwd() + '/libs/'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment