Pārlūkot izejas kodu

finished upload files

unknown 3 gadi atpakaļ
vecāks
revīzija
29161c72d5

BIN
audios/62275dbc1f60894d30cce0c9/audio_mpeg (1).mp3


BIN
audios/62275e151f60894d30cce0ca/audio_mpeg.mp3


+ 13 - 2
controllers/messages.js

@@ -147,6 +147,7 @@ const audioMessage = async (req, res, next) => {
 		const DIR_AUDIOS = process.env.DIR_AUDIOS;
 		const pathToFile = req.file.path;
 		const newNameAudio = req.file.originalname;
+		const fullType = req.file.mimetype;
 		await createFolderIsExist(path.join(DIR_AUDIOS, userId));
 		await fs.rename(pathToFile, path.join(DIR_AUDIOS, userId, newNameAudio));
 		const audioUrl = path.normalize(path.join(userId, newNameAudio));
@@ -160,6 +161,7 @@ const audioMessage = async (req, res, next) => {
 				color,
 				number,
 				type: 'audio',
+				fullType,
 				companionId: id,
 				owner: userId,
 			});
@@ -171,6 +173,7 @@ const audioMessage = async (req, res, next) => {
 				color,
 				number,
 				type: 'audio',
+				fullType,
 				companionId: userId,
 				owner: id,
 			});
@@ -198,6 +201,7 @@ const videoMessage = async (req, res, next) => {
 		const DIR_VIDEOS = process.env.DIR_VIDEOS;
 		const pathToFile = req.file.path;
 		const newNameVideo = req.file.originalname;
+		const fullType = req.file.mimetype;
 		await createFolderIsExist(path.join(DIR_VIDEOS, userId));
 		await fs.rename(pathToFile, path.join(DIR_VIDEOS, userId, newNameVideo));
 		const videoUrl = path.normalize(path.join(userId, newNameVideo));
@@ -211,6 +215,7 @@ const videoMessage = async (req, res, next) => {
 				color,
 				number,
 				type: 'video',
+				fullType,
 				companionId: id,
 				owner: userId,
 			});
@@ -222,6 +227,7 @@ const videoMessage = async (req, res, next) => {
 				color,
 				number,
 				type: 'video',
+				fullType,
 				companionId: userId,
 				owner: id,
 			});
@@ -249,18 +255,21 @@ const fileMessage = async (req, res, next) => {
 		const DIR_FILES = process.env.DIR_FILES;
 		const pathToFile = req.file.path;
 		const newNameFile = req.file.originalname;
+		const fullType = req.file.mimetype;
 		let type;
-		switch (req.file.mimetype) {
+		switch (fullType) {
 			case 'application/pdf':
 				type = 'pdf';
 				break;
 			case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
 				type = 'docx';
 				break;
+			case 'application/octet-stream':
+				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));
@@ -274,6 +283,7 @@ const fileMessage = async (req, res, next) => {
 				color,
 				number,
 				type,
+				fullType,
 				companionId: id,
 				owner: userId,
 			});
@@ -285,6 +295,7 @@ const fileMessage = async (req, res, next) => {
 				color,
 				number,
 				type,
+				fullType,
 				companionId: userId,
 				owner: id,
 			});

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


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


BIN
files/62275e151f60894d30cce0ca/GrigoreCvUa.pdf


BIN
files/62275e151f60894d30cce0ca/React GUI Developer Cork, Ireland (1).docx


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


BIN
images/62275dbc1f60894d30cce0c9/download (1).jpg


BIN
images/62275e151f60894d30cce0ca/download (1).jpg


+ 4 - 0
model/schemas/message.js

@@ -38,6 +38,10 @@ const messageSchema = new Schema(
 			type: String,
 			default: null,
 		},
+		fullType: {
+			type: String,
+			default: null,
+		},
 		owner: {
 			type: SchemaTypes.ObjectId,
 			ref: 'user',

BIN
videos/62275dbc1f60894d30cce0c9/video_mp4 (1).mp4


BIN
videos/62275e151f60894d30cce0ca/video_mp4 (1).mp4