mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-20 06:26:13 +01:00
* support for other s3 providers * remove redundant route options * use type safe env * prettier
16 lines
561 B
TypeScript
16 lines
561 B
TypeScript
import { randomId } from '@/lib/api'
|
|
import { env } from '@/lib/env'
|
|
import { POST as route } from 'next-s3-upload/route'
|
|
|
|
export const POST = route.configure({
|
|
key(req, filename) {
|
|
const [, extension] = filename.match(/(\.[^\.]*)$/) ?? [null, '']
|
|
const timestamp = new Date().toISOString()
|
|
const random = randomId()
|
|
return `document-${timestamp}-${random}${extension.toLowerCase()}`
|
|
},
|
|
endpoint: env.S3_UPLOAD_ENDPOINT,
|
|
// forcing path style is only necessary for providers other than AWS
|
|
forcePathStyle: !!env.S3_UPLOAD_ENDPOINT,
|
|
})
|