aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-13 18:17:05 +0100
committerChocobozzz <me@florianbigard.com>2018-02-14 16:03:09 +0100
commitac81d1a06d57b9ae86663831e7f5edcef57b0fa4 (patch)
treeda31775c9533d3e270f68f921e146f086bf7c0b8 /server/helpers/utils.ts
parente883399fa6caa56bb8519c9a2e22d88001f26661 (diff)
downloadPeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.tar.gz
PeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.tar.zst
PeerTube-ac81d1a06d57b9ae86663831e7f5edcef57b0fa4.zip
Add ability to set video thumbnail/preview
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r--server/helpers/utils.ts18
1 files changed, 15 insertions, 3 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 79c3b5858..3b618360b 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -27,10 +27,14 @@ function badRequest (req: express.Request, res: express.Response, next: express.
27 return res.type('json').status(400).end() 27 return res.type('json').status(400).end()
28} 28}
29 29
30function createReqFiles (fieldName: string, storageDir: string, mimeTypes: { [ id: string ]: string }) { 30function createReqFiles (
31 fieldNames: string[],
32 mimeTypes: { [ id: string ]: string },
33 destinations: { [ fieldName: string ]: string }
34) {
31 const storage = multer.diskStorage({ 35 const storage = multer.diskStorage({
32 destination: (req, file, cb) => { 36 destination: (req, file, cb) => {
33 cb(null, storageDir) 37 cb(null, destinations[file.fieldname])
34 }, 38 },
35 39
36 filename: async (req, file, cb) => { 40 filename: async (req, file, cb) => {
@@ -48,7 +52,15 @@ function createReqFiles (fieldName: string, storageDir: string, mimeTypes: { [ i
48 } 52 }
49 }) 53 })
50 54
51 return multer({ storage }).fields([{ name: fieldName, maxCount: 1 }]) 55 const fields = []
56 for (const fieldName of fieldNames) {
57 fields.push({
58 name: fieldName,
59 maxCount: 1
60 })
61 }
62
63 return multer({ storage }).fields(fields)
52} 64}
53 65
54async function generateRandomString (size: number) { 66async function generateRandomString (size: number) {