aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-04 10:57:36 +0100
committerChocobozzz <me@florianbigard.com>2022-03-04 10:57:36 +0100
commitd3d3deaa7aae49d6d949aebcba015af75d292ccc (patch)
tree42e487810f5b7362c28f744371d160a4effc7566 /server/helpers
parent90370f7cc85ee4b45eb0d1bafed2d9d68610df9f (diff)
downloadPeerTube-d3d3deaa7aae49d6d949aebcba015af75d292ccc.tar.gz
PeerTube-d3d3deaa7aae49d6d949aebcba015af75d292ccc.tar.zst
PeerTube-d3d3deaa7aae49d6d949aebcba015af75d292ccc.zip
Refactor user build and express file middlewares
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/express-utils.ts7
1 files changed, 3 insertions, 4 deletions
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts
index 08f77966f..82dd4c178 100644
--- a/server/helpers/express-utils.ts
+++ b/server/helpers/express-utils.ts
@@ -68,11 +68,11 @@ function badRequest (_req: express.Request, res: express.Response) {
68function createReqFiles ( 68function createReqFiles (
69 fieldNames: string[], 69 fieldNames: string[],
70 mimeTypes: { [id: string]: string | string[] }, 70 mimeTypes: { [id: string]: string | string[] },
71 destinations: { [fieldName: string]: string } 71 destination = CONFIG.STORAGE.TMP_DIR
72): RequestHandler { 72): RequestHandler {
73 const storage = diskStorage({ 73 const storage = diskStorage({
74 destination: (req, file, cb) => { 74 destination: (req, file, cb) => {
75 cb(null, destinations[file.fieldname]) 75 cb(null, destination)
76 }, 76 },
77 77
78 filename: (req, file, cb) => { 78 filename: (req, file, cb) => {
@@ -93,12 +93,11 @@ function createReqFiles (
93 93
94function createAnyReqFiles ( 94function createAnyReqFiles (
95 mimeTypes: { [id: string]: string | string[] }, 95 mimeTypes: { [id: string]: string | string[] },
96 destinationDirectory: string,
97 fileFilter: (req: express.Request, file: Express.Multer.File, cb: (err: Error, result: boolean) => void) => void 96 fileFilter: (req: express.Request, file: Express.Multer.File, cb: (err: Error, result: boolean) => void) => void
98): RequestHandler { 97): RequestHandler {
99 const storage = diskStorage({ 98 const storage = diskStorage({
100 destination: (req, file, cb) => { 99 destination: (req, file, cb) => {
101 cb(null, destinationDirectory) 100 cb(null, CONFIG.STORAGE.TMP_DIR)
102 }, 101 },
103 102
104 filename: (req, file, cb) => { 103 filename: (req, file, cb) => {