2021-12-03 14:00:40 +01:00
|
|
|
import express from 'express'
|
2022-10-28 10:47:06 +02:00
|
|
|
import { buildLogger } from '@server/helpers/logger'
|
2021-12-03 14:00:40 +01:00
|
|
|
import { getResumableUploadPath } from '@server/helpers/upload'
|
2022-11-07 10:40:43 +01:00
|
|
|
import { CONFIG } from '@server/initializers/config'
|
|
|
|
import { LogLevel, Uploadx } from '@uploadx/core'
|
|
|
|
|
|
|
|
const logger = buildLogger('uploadx')
|
2021-12-03 14:00:40 +01:00
|
|
|
|
2021-12-17 15:49:52 +01:00
|
|
|
const uploadx = new Uploadx({
|
|
|
|
directory: getResumableUploadPath(),
|
2022-04-19 11:44:03 +02:00
|
|
|
|
|
|
|
expiration: { maxAge: undefined, rolling: true },
|
|
|
|
|
2021-12-17 15:49:52 +01:00
|
|
|
// Could be big with thumbnails/previews
|
2022-01-18 09:29:46 +01:00
|
|
|
maxMetadataSize: '10MB',
|
2022-04-19 11:44:03 +02:00
|
|
|
|
2022-11-07 10:40:43 +01:00
|
|
|
logger: {
|
|
|
|
logLevel: CONFIG.LOG.LEVEL as LogLevel,
|
|
|
|
debug: logger.debug.bind(logger),
|
|
|
|
info: logger.info.bind(logger),
|
|
|
|
warn: logger.warn.bind(logger),
|
|
|
|
error: logger.error.bind(logger)
|
|
|
|
},
|
2022-10-28 10:47:06 +02:00
|
|
|
|
2022-01-18 09:29:46 +01:00
|
|
|
userIdentifier: (_, res: express.Response) => {
|
|
|
|
if (!res.locals.oauth) return undefined
|
|
|
|
|
|
|
|
return res.locals.oauth.token.user.id + ''
|
|
|
|
}
|
2021-12-17 15:49:52 +01:00
|
|
|
})
|
2021-12-03 14:00:40 +01:00
|
|
|
|
|
|
|
export {
|
|
|
|
uploadx
|
|
|
|
}
|