1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Add ability to set video thumbnail/preview

This commit is contained in:
Chocobozzz 2018-02-13 18:17:05 +01:00
parent e883399fa6
commit ac81d1a06d
No known key found for this signature in database
GPG key ID: 583A612D890159BE
22 changed files with 454 additions and 143 deletions

View file

@ -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) {