improvement: better media filename handle

This commit is contained in:
canove
2020-08-04 10:07:03 -03:00
parent c0817e99d1
commit 7a99abe543
3 changed files with 8 additions and 8 deletions

View File

@@ -17,12 +17,13 @@ const TicketsRoutes = require("./routes/tickets");
const WhatsRoutes = require("./routes/whatsapp");
const app = express();
const fileStorage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, path.resolve(__dirname, "..", "public"));
},
filename: (req, file, cb) => {
cb(null, new Date().getTime() + "-" + file.originalname.replace(/\s/g, ""));
cb(null, new Date().getTime() + path.extname(file.originalname));
},
});
@@ -55,7 +56,7 @@ const io = require("./libs/socket").init(server);
io.on("connection", socket => {
console.log("Client Connected");
socket.on("joinChatBox", ticketId => {
console.log("A client joined in a ticket channel");
console.log("A client joined a ticket channel");
socket.join(ticketId);
});