We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 091cd02 commit 7695ffdCopy full SHA for 7695ffd
src/app/api/s3-upload/route.ts
@@ -1,8 +1,11 @@
1
-import { sanitizeKey } from 'next-s3-upload'
+import { randomId } from '@/lib/api'
2
import { POST as route } from 'next-s3-upload/route'
3
4
export const POST = route.configure({
5
key(req, filename) {
6
- return sanitizeKey(filename).toLowerCase()
+ const [, extension] = filename.match(/(\.[^\.]*)$/) ?? [null, '']
7
+ const timestamp = new Date().toISOString()
8
+ const random = randomId()
9
+ return `document-${timestamp}-${random}${extension.toLowerCase()}`
10
},
11
})
0 commit comments