]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/uploadx.ts
Update translations
[github/Chocobozzz/PeerTube.git] / server / lib / uploadx.ts
1 import express from 'express'
2 import { buildLogger } from '@server/helpers/logger'
3 import { getResumableUploadPath } from '@server/helpers/upload'
4 import { CONFIG } from '@server/initializers/config'
5 import { LogLevel, Uploadx } from '@uploadx/core'
6 import { extname } from 'path'
7
8 const logger = buildLogger('uploadx')
9
10 const uploadx = new Uploadx({
11 directory: getResumableUploadPath(),
12
13 expiration: { maxAge: undefined, rolling: true },
14
15 // Could be big with thumbnails/previews
16 maxMetadataSize: '10MB',
17
18 logger: {
19 logLevel: CONFIG.LOG.LEVEL as LogLevel,
20 debug: logger.debug.bind(logger),
21 info: logger.info.bind(logger),
22 warn: logger.warn.bind(logger),
23 error: logger.error.bind(logger)
24 },
25
26 userIdentifier: (_, res: express.Response) => {
27 if (!res.locals.oauth) return undefined
28
29 return res.locals.oauth.token.user.id + ''
30 },
31
32 filename: file => `${file.userId}-${file.id}${extname(file.metadata.filename)}`
33 })
34
35 export {
36 uploadx
37 }