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