Skip to content

Commit 64a2329

Browse files
committed
Merge remote-tracking branch 'base/main'
2 parents a8f0766 + 7695ffd commit 64a2329

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/app/api/s3-upload/route.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { sanitizeKey } from 'next-s3-upload'
1+
import { randomId } from '@/lib/api'
22
import { POST as route } from 'next-s3-upload/route'
33

44
export const POST = route.configure({
55
key(req, filename) {
6-
return sanitizeKey(filename).toLowerCase()
6+
const [, extension] = filename.match(/(\.[^\.]*)$/) ?? [null, '']
7+
const timestamp = new Date().toISOString()
8+
const random = randomId()
9+
return `document-${timestamp}-${random}${extension.toLowerCase()}`
710
},
811
})

0 commit comments

Comments
 (0)