mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-05 20:26:11 +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'
|
import { POST as route } from 'next-s3-upload/route'
|
||||||
|
|
||||||
export const POST = route.configure({
|
export const POST = route.configure({
|
||||||
key(req, filename) {
|
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