Browse Source

done caruosel

unknown 3 years ago
parent
commit
4cf62cb323

BIN
audios/62275dbc1f60894d30cce0c9/song.mp3


+ 14 - 2
controllers/messages.js

@@ -249,6 +249,18 @@ const fileMessage = async (req, res, next) => {
 		const DIR_FILES = process.env.DIR_FILES;
 		const pathToFile = req.file.path;
 		const newNameFile = req.file.originalname;
+		let type;
+		switch (req.file.mimetype) {
+			case 'application/pdf':
+				type = 'pdf';
+				break;
+			case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
+				type = 'docx';
+				break;
+			default:
+				break;
+		}
+		console.log(req.file, req.file.mimetype);
 		await createFolderIsExist(path.join(DIR_FILES, userId));
 		await fs.rename(pathToFile, path.join(DIR_FILES, userId, newNameFile));
 		const fileUrl = path.normalize(path.join(userId, newNameFile));
@@ -261,7 +273,7 @@ const fileMessage = async (req, res, next) => {
 				avatarUrl,
 				color,
 				number,
-				type: 'file',
+				type,
 				companionId: id,
 				owner: userId,
 			});
@@ -272,7 +284,7 @@ const fileMessage = async (req, res, next) => {
 				avatarUrl,
 				color,
 				number,
-				type: 'file',
+				type,
 				companionId: userId,
 				owner: id,
 			});

BIN
files/62275dbc1f60894d30cce0c9/GrigoreCV.pdf


BIN
files/62275dbc1f60894d30cce0c9/React GUI Developer Cork, Ireland .docx


BIN
files/62275e151f60894d30cce0ca/English File (4th ed) Upper-Intermediate - WB.pdf


BIN
images/62275dbc1f60894d30cce0c9/nature-g0393aaedf_1920.jpg