mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-11 10:06:13 +01:00
Fix uploaded image names
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import { sanitizeKey } from 'next-s3-upload'
|
||||
import { randomId } from '@/lib/api'
|
||||
import { POST as route } from 'next-s3-upload/route'
|
||||
|
||||
export const POST = route.configure({
|
||||
key(req, filename) {
|
||||
return sanitizeKey(filename).toLowerCase()
|
||||
const [, extension] = filename.match(/(\.[^\.]*)$/) ?? [null, '']
|
||||
const timestamp = new Date().toISOString()
|
||||
const random = randomId()
|
||||
return `document-${timestamp}-${random}${extension.toLowerCase()}`
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user