This commit is contained in:
Gregoire Parant 2020-09-23 18:28:12 +02:00
parent d5fdb9d857
commit 4beeb62c6f
4 changed files with 2254 additions and 21 deletions

View File

@ -39,7 +39,6 @@
"@types/express": "^4.17.4",
"@types/http-status-codes": "^1.2.0",
"@types/jsonwebtoken": "^8.3.8",
"@types/multer": "^1.4.4",
"@types/socket.io": "^2.1.4",
"@types/uuidv4": "^5.0.0",
"axios": "^0.20.0",

View File

@ -1,12 +1,23 @@
const multer = require('multer');
import {Application, Request, RequestHandler, Response} from "express";
import {OK} from "http-status-codes";
import {URL_ROOM_STARTED} from "_Enum/EnvironmentVariable";
import {uuid} from "uuidv4";
import multer from 'multer';
import fs from "fs";
const upload = multer({ dest: 'dist/files/' });
class FileUpload{
path: string
constructor(path : string) {
this.path = path;
}
}
interface RequestFileHandlerInterface extends Request{
file: FileUpload
}
export class FileController {
App : Application;
@ -22,8 +33,8 @@ export class FileController {
//TODO upload audio message
const audioMessageId = uuid();
fs.copyFileSync(req.file.path, `dist/files/${audioMessageId}`);
fs.unlinkSync(req.file.path);
fs.copyFileSync((req as RequestFileHandlerInterface).file.path, `dist/files/${audioMessageId}`);
fs.unlinkSync((req as RequestFileHandlerInterface).file.path);
return res.status(OK).send({
id: audioMessageId,

View File

@ -48,16 +48,6 @@
"@types/node" "*"
"@types/range-parser" "*"
"@types/express@*":
version "4.17.8"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.8.tgz#3df4293293317e61c60137d273a2e96cd8d5f27a"
integrity sha512-wLhcKh3PMlyA2cNAB9sjM1BntnhPMiM0JOBwPBqttjHev2428MLEB4AYVN+d8s2iyCVZac+o41Pflm/ZH5vLXQ==
dependencies:
"@types/body-parser" "*"
"@types/express-serve-static-core" "*"
"@types/qs" "*"
"@types/serve-static" "*"
"@types/express@^4.17.4":
version "4.17.4"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.4.tgz#e78bf09f3f530889575f4da8a94cd45384520aac"
@ -91,13 +81,6 @@
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d"
"@types/multer@^1.4.4":
version "1.4.4"
resolved "https://registry.yarnpkg.com/@types/multer/-/multer-1.4.4.tgz#bb5d9abc410da82726ceca74008bb81813349a88"
integrity sha512-wdfkiKBBEMTODNbuF3J+qDDSqJxt50yB9pgDiTcFew7f97Gcc7/sM4HR66ofGgpJPOALWOqKAch4gPyqEXSkeQ==
dependencies:
"@types/express" "*"
"@types/node@*":
version "13.11.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b"

2240
maps/yarn.lock Normal file

File diff suppressed because it is too large Load Diff