diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-13 18:17:05 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-14 16:03:09 +0100 |
commit | ac81d1a06d57b9ae86663831e7f5edcef57b0fa4 (patch) | |
tree | da31775c9533d3e270f68f921e146f086bf7c0b8 /server/helpers/utils.ts | |
parent | e883399fa6caa56bb8519c9a2e22d88001f26661 (diff) | |
download | PeerTube-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.ts | 18 |
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 | ||
30 | function createReqFiles (fieldName: string, storageDir: string, mimeTypes: { [ id: string ]: string }) { | 30 | function 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 | ||
54 | async function generateRandomString (size: number) { | 66 | async function generateRandomString (size: number) { |