X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Futils.ts;h=3b618360bc25c52b37a86734c7a00d430e9cf958;hb=73c695919c6569bfb667c36fc5a6b9b862130a0d;hp=7a32e286ca56a9c5c341dd03699bfad7a37b293f;hpb=c5911fd347c76e8bdc05ea9f3ee9efed4a58c236;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 7a32e286c..3b618360b 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts @@ -3,7 +3,7 @@ import * as multer from 'multer' import { Model } from 'sequelize-typescript' import { ResultList } from '../../shared' import { VideoResolution } from '../../shared/models/videos' -import { CONFIG, REMOTE_SCHEME, VIDEO_MIMETYPE_EXT } from '../initializers' +import { CONFIG, REMOTE_SCHEME } from '../initializers' import { UserModel } from '../models/account/user' import { ActorModel } from '../models/activitypub/actor' import { ApplicationModel } from '../models/application/application' @@ -27,10 +27,14 @@ function badRequest (req: express.Request, res: express.Response, next: express. return res.type('json').status(400).end() } -function createReqFiles (fieldName: string, storageDir: string, mimeTypes: { [ id: string ]: string }) { +function createReqFiles ( + fieldNames: string[], + mimeTypes: { [ id: string ]: string }, + destinations: { [ fieldName: string ]: string } +) { const storage = multer.diskStorage({ destination: (req, file, cb) => { - cb(null, storageDir) + cb(null, destinations[file.fieldname]) }, filename: async (req, file, cb) => { @@ -48,7 +52,15 @@ function createReqFiles (fieldName: string, storageDir: string, mimeTypes: { [ i } }) - return multer({ storage }).fields([{ name: fieldName, maxCount: 1 }]) + const fields = [] + for (const fieldName of fieldNames) { + fields.push({ + name: fieldName, + maxCount: 1 + }) + } + + return multer({ storage }).fields(fields) } async function generateRandomString (size: number) { @@ -104,7 +116,7 @@ function computeResolutionsToTranscode (videoFileHeight: number) { ] for (const resolution of resolutions) { - if (configResolutions[resolution.toString()] === true && videoFileHeight > resolution) { + if (configResolutions[resolution + 'p'] === true && videoFileHeight > resolution) { resolutionsEnabled.push(resolution) } }